# Author: Will Rodman
# wrodman@tulane.edu
#
# Command line to run program:
# python3 pyfrechet_visualize.py

import sys, os, unittest
sys.path.insert(0, "../")
from pyfrechet.distance import StrongDistance
from pyfrechet.visualize import FreeSpaceDiagram, Trajectories

TEST_DATA = "sp500"

if TEST_DATA == "sp500":
    REACHABLE_EPSILON = 5
    UNREACHABLE_EPSILON = 1
    REVERSE_CURVE = False

elif TEST_DATA == "trajectory":
    REACHABLE_EPSILON = 70
    UNREACHABLE_EPSILON = 60
    REVERSE_CURVE = True

CURVE_1 = f"{TEST_DATA}_data/sample_1.txt"
CURVE_2 = f"{TEST_DATA}_data/sample_2.txt"

class pyfrechet_optimise(unittest.TestCase):

    global REACHABLE_EPSILON
    global UNREACHABLE_EPSILON
    global REVERSE_CURVE

    global CURVE_1
    global CURVE_2

    def test_fail_BinarySearch_instance_argument(self):
        class BadClass(): pass
        with self.assertRaises(TypeError):
            bc = BadClass()
            FreeSpaceDiagram(bc)

    def test_FreeSpaceDiagram_plot(self):
        sd = StrongDistance.setCurves(CURVE_1, CURVE_2, REVERSE_CURVE)
        sd.setFreeSpace(REACHABLE_EPSILON)
        fsd = FreeSpaceDiagram(sd)
        fsd.plot()

    def test_FreeSpaceDiagram__addEpsilonSlider(self):
        sd = StrongDistance.setCurves(CURVE_1, CURVE_2, REVERSE_CURVE)
        fsd = FreeSpaceDiagram(sd)
        fsd.addEpsilonSlider(UNREACHABLE_EPSILON, REACHABLE_EPSILON, 1)
        fsd.plot()

    def test_FreeSpaceDiagram__weighted_cells(self):
        sd = StrongDistance.setCurves(CURVE_1, CURVE_2, REVERSE_CURVE)
        fsd = FreeSpaceDiagram(sd)
        sd.setFreeSpace(REACHABLE_EPSILON)
        fsd.plot(True, False)

    def test_FreeSpaceDiagram__gridlines(self):
        sd = StrongDistance.setCurves(CURVE_1, CURVE_2, REVERSE_CURVE)
        fsd = FreeSpaceDiagram(sd)
        sd.setFreeSpace(REACHABLE_EPSILON)
        fsd.plot(True, True)

    def test_Trajectories(self):
        sd = StrongDistance.setCurves(CURVE_1, CURVE_2, REVERSE_CURVE)
        t = Trajectories(sd)
        t.plot()

    

if __name__ == '__main__':
    unittest.main()

[((8, 0, 8, 25), 'sys.path.insert', 'sys.path.insert', ({(8, 16, 8, 17): '(0)', (8, 19, 8, 24): '"""../"""'}, {}), "(0, '../')", False, 'import sys, os, unittest\n'), ((74, 4, 74, 19), 'unittest.main', 'unittest.main', ({}, {}), '()', False, 'import sys, os, unittest\n'), ((43, 13, 43, 70), 'pyfrechet.distance.StrongDistance.setCurves', 'StrongDistance.setCurves', ({(43, 38, 43, 45): 'CURVE_1', (43, 47, 43, 54): 'CURVE_2', (43, 56, 43, 69): 'REVERSE_CURVE'}, {}), '(CURVE_1, CURVE_2, REVERSE_CURVE)', False, 'from pyfrechet.distance import StrongDistance\n'), ((45, 14, 45, 34), 'pyfrechet.visualize.FreeSpaceDiagram', 'FreeSpaceDiagram', ({(45, 31, 45, 33): 'sd'}, {}), '(sd)', False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n'), ((49, 13, 49, 70), 'pyfrechet.distance.StrongDistance.setCurves', 'StrongDistance.setCurves', ({(49, 38, 49, 45): 'CURVE_1', (49, 47, 49, 54): 'CURVE_2', (49, 56, 49, 69): 'REVERSE_CURVE'}, {}), '(CURVE_1, CURVE_2, REVERSE_CURVE)', False, 'from pyfrechet.distance import StrongDistance\n'), ((50, 14, 50, 34), 'pyfrechet.visualize.FreeSpaceDiagram', 'FreeSpaceDiagram', ({(50, 31, 50, 33): 'sd'}, {}), '(sd)', False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n'), ((55, 13, 55, 70), 'pyfrechet.distance.StrongDistance.setCurves', 'StrongDistance.setCurves', ({(55, 38, 55, 45): 'CURVE_1', (55, 47, 55, 54): 'CURVE_2', (55, 56, 55, 69): 'REVERSE_CURVE'}, {}), '(CURVE_1, CURVE_2, REVERSE_CURVE)', False, 'from pyfrechet.distance import StrongDistance\n'), ((56, 14, 56, 34), 'pyfrechet.visualize.FreeSpaceDiagram', 'FreeSpaceDiagram', ({(56, 31, 56, 33): 'sd'}, {}), '(sd)', False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n'), ((61, 13, 61, 70), 'pyfrechet.distance.StrongDistance.setCurves', 'StrongDistance.setCurves', ({(61, 38, 61, 45): 'CURVE_1', (61, 47, 61, 54): 'CURVE_2', (61, 56, 61, 69): 'REVERSE_CURVE'}, {}), '(CURVE_1, CURVE_2, REVERSE_CURVE)', False, 'from pyfrechet.distance import StrongDistance\n'), ((62, 14, 62, 34), 'pyfrechet.visualize.FreeSpaceDiagram', 'FreeSpaceDiagram', ({(62, 31, 62, 33): 'sd'}, {}), '(sd)', False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n'), ((67, 13, 67, 70), 'pyfrechet.distance.StrongDistance.setCurves', 'StrongDistance.setCurves', ({(67, 38, 67, 45): 'CURVE_1', (67, 47, 67, 54): 'CURVE_2', (67, 56, 67, 69): 'REVERSE_CURVE'}, {}), '(CURVE_1, CURVE_2, REVERSE_CURVE)', False, 'from pyfrechet.distance import StrongDistance\n'), ((68, 12, 68, 28), 'pyfrechet.visualize.Trajectories', 'Trajectories', ({(68, 25, 68, 27): 'sd'}, {}), '(sd)', False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n'), ((40, 12, 40, 32), 'pyfrechet.visualize.FreeSpaceDiagram', 'FreeSpaceDiagram', ({(40, 29, 40, 31): 'bc'}, {}), '(bc)', False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n')]