1
0
Fork 0

Added Tests for TrajectoryGenerator

master
Pietro 4 years ago
parent 2792c7aaaf
commit f01817f2bc
  1. 15
      test_trajectorygenerator.py

@ -22,12 +22,17 @@ class TestTrajectoryGenerator(unittest.TestCase):
tg = TrajectoryGenerator(self.j1) tg = TrajectoryGenerator(self.j1)
end_time = random.randint(5, 100) end_time = random.randint(5, 100)
sigma = tg.CTBN_Sample(end_time) sigma = tg.CTBN_Sample(end_time)
self.assertLessEqual(sigma.times.loc[len(sigma) - 1].at["Time"], end_time) self.assertLessEqual(sigma.times[len(sigma.times) - 1], end_time)
for index, row in sigma.iterrows(): for index in range(len(sigma.times)):
if index > 0: if index > 0:
self.assertLess(sigma.times.loc[index - 1].at["Time"], row.at["Time"]) self.assertLess(sigma.times[index - 1], sigma.times[index])
diff = abs(sum(sigma.loc[index - 1, sigma.columns != "Time"]) - diff = abs(sum(sigma.trajectory[index - 1]) - sum(sigma.trajectory[index]))
sum(sigma.loc[index, sigma.columns != "Time"]))
self.assertEqual(diff, 1) self.assertEqual(diff, 1)
def test_generated_trajectory_max_tr(self):
tg = TrajectoryGenerator(self.j1)
n_tr = random.randint(5, 100)
sigma = tg.CTBN_Sample(max_tr = n_tr)
self.assertEqual(len(sigma.times), n_tr + 1)
unittest.main() unittest.main()