From 59de29905345a2e6d6146d3d48270f46af89772b Mon Sep 17 00:00:00 2001 From: Pietro Date: Sun, 25 Apr 2021 15:45:14 +0200 Subject: [PATCH] Test --- .../tests/structure_graph/test_networkgenerator.py | 0 .../tests/structure_graph/test_trajectorygenerator.py | 7 +++++-- 2 files changed, 5 insertions(+), 2 deletions(-) rename test_networkgenerator.py => PyCTBN/tests/structure_graph/test_networkgenerator.py (100%) rename test_trajectorygenerator.py => PyCTBN/tests/structure_graph/test_trajectorygenerator.py (83%) diff --git a/test_networkgenerator.py b/PyCTBN/tests/structure_graph/test_networkgenerator.py similarity index 100% rename from test_networkgenerator.py rename to PyCTBN/tests/structure_graph/test_networkgenerator.py diff --git a/test_trajectorygenerator.py b/PyCTBN/tests/structure_graph/test_trajectorygenerator.py similarity index 83% rename from test_trajectorygenerator.py rename to PyCTBN/tests/structure_graph/test_trajectorygenerator.py index ad13b6b..3146ed3 100644 --- a/test_trajectorygenerator.py +++ b/PyCTBN/tests/structure_graph/test_trajectorygenerator.py @@ -9,6 +9,7 @@ class TestTrajectoryGenerator(unittest.TestCase): @classmethod def setUpClass(cls) -> None: cls.j1 = JsonImporter("./PyCTBN/test_data/networks_and_trajectories_binary_data_01_3.json", "samples", "dyn.str", "variables", "Time", "Name") + cls.j1.import_data(0) def test_init(self): tg = TrajectoryGenerator(self.j1) @@ -28,8 +29,10 @@ class TestTrajectoryGenerator(unittest.TestCase): for index in range(len(traj.times)): if index > 0: self.assertLess(traj.times[index - 1], traj.times[index]) - diff = abs(sum(traj.trajectory[index - 1]) - sum(traj.trajectory[index])) - self.assertEqual(diff, 1) + if index < len(traj.times) - 1: + diff = abs(sum(traj.trajectory[index - 1]) - sum(traj.trajectory[index])) + self.assertEqual(diff, 1) + self.assertEqual(sum(traj.trajectory[len(traj.times) - 1]), -1 * len(self.j1.sorter)) def test_generated_trajectory_max_tr(self): tg = TrajectoryGenerator(self.j1)