# 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()

[((135, 160), 'sys.path.insert', 'sys.path.insert', (['(0)', '"""../"""'], {}), "(0, '../')\n", (150, 160), False, 'import sys, os, unittest\n'), ((2074, 2089), 'unittest.main', 'unittest.main', ([], {}), '()\n', (2087, 2089), False, 'import sys, os, unittest\n'), ((1017, 1074), 'pyfrechet.distance.StrongDistance.setCurves', 'StrongDistance.setCurves', (['CURVE_1', 'CURVE_2', 'REVERSE_CURVE'], {}), '(CURVE_1, CURVE_2, REVERSE_CURVE)\n', (1041, 1074), False, 'from pyfrechet.distance import StrongDistance\n'), ((1132, 1152), 'pyfrechet.visualize.FreeSpaceDiagram', 'FreeSpaceDiagram', (['sd'], {}), '(sd)\n', (1148, 1152), False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n'), ((1241, 1298), 'pyfrechet.distance.StrongDistance.setCurves', 'StrongDistance.setCurves', (['CURVE_1', 'CURVE_2', 'REVERSE_CURVE'], {}), '(CURVE_1, CURVE_2, REVERSE_CURVE)\n', (1265, 1298), False, 'from pyfrechet.distance import StrongDistance\n'), ((1313, 1333), 'pyfrechet.visualize.FreeSpaceDiagram', 'FreeSpaceDiagram', (['sd'], {}), '(sd)\n', (1329, 1333), False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n'), ((1492, 1549), 'pyfrechet.distance.StrongDistance.setCurves', 'StrongDistance.setCurves', (['CURVE_1', 'CURVE_2', 'REVERSE_CURVE'], {}), '(CURVE_1, CURVE_2, REVERSE_CURVE)\n', (1516, 1549), False, 'from pyfrechet.distance import StrongDistance\n'), ((1564, 1584), 'pyfrechet.visualize.FreeSpaceDiagram', 'FreeSpaceDiagram', (['sd'], {}), '(sd)\n', (1580, 1584), False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n'), ((1720, 1777), 'pyfrechet.distance.StrongDistance.setCurves', 'StrongDistance.setCurves', (['CURVE_1', 'CURVE_2', 'REVERSE_CURVE'], {}), '(CURVE_1, CURVE_2, REVERSE_CURVE)\n', (1744, 1777), False, 'from pyfrechet.distance import StrongDistance\n'), ((1792, 1812), 'pyfrechet.visualize.FreeSpaceDiagram', 'FreeSpaceDiagram', (['sd'], {}), '(sd)\n', (1808, 1812), False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n'), ((1932, 1989), 'pyfrechet.distance.StrongDistance.setCurves', 'StrongDistance.setCurves', (['CURVE_1', 'CURVE_2', 'REVERSE_CURVE'], {}), '(CURVE_1, CURVE_2, REVERSE_CURVE)\n', (1956, 1989), False, 'from pyfrechet.distance import StrongDistance\n'), ((2002, 2018), 'pyfrechet.visualize.Trajectories', 'Trajectories', (['sd'], {}), '(sd)\n', (2014, 2018), False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n'), ((940, 960), 'pyfrechet.visualize.FreeSpaceDiagram', 'FreeSpaceDiagram', (['bc'], {}), '(bc)\n', (956, 960), False, 'from pyfrechet.visualize import FreeSpaceDiagram, Trajectories\n')]