Example #1
0
    def test_sort(self):
        l1 = LabelTimeBoardingsAndRoute(departure_time=1,
                                        arrival_time_target=1,
                                        movement_duration=3,
                                        n_boardings=1,
                                        first_leg_is_walk=False)
        l2 = LabelTimeBoardingsAndRoute(0, 0, 0, 1, False)
        self.assertTrue(l1 > l2)
        self.assertTrue(l1 >= l2)
        self.assertFalse(l1 < l2)
        self.assertFalse(l1 <= l2)

        l1 = LabelTimeBoardingsAndRoute(0, 0, 0, 1, False)
        l2 = LabelTimeBoardingsAndRoute(0, 0, 0, 1, False)
        self.assertTrue(l1 == l2)
        self.assertTrue(l1 >= l2)
        self.assertTrue(l1 <= l2)
        self.assertFalse(l1 != l2)

        l1 = LabelTimeBoardingsAndRoute(1, 0, 10, 1, False)
        l2 = LabelTimeBoardingsAndRoute(1, 1, 10, 1, False)
        self.assertTrue(l1 > l2)
        self.assertFalse(l1 < l2)

        l1 = LabelTimeBoardingsAndRoute(1, 1, 0, 1, False)
        l2 = LabelTimeBoardingsAndRoute(1, 1, 10, 1, False)
        self.assertTrue(l1 > l2)
        self.assertFalse(l1 < l2)

        self.assertTrue(sorted([l1, l2])[0] == l2)

        l1 = LabelTimeBoardingsAndRoute(1, 1, 10, 1, True)
        l2 = LabelTimeBoardingsAndRoute(1, 1, 10, 1, False)
        self.assertTrue(l1 < l2)
        self.assertFalse(l1 > l2)
Example #2
0
 def test_duration(self):
     label1 = LabelTimeBoardingsAndRoute(departure_time=0,
                                         arrival_time_target=20,
                                         movement_duration=1,
                                         n_boardings=1,
                                         first_leg_is_walk=False)
     self.assertEqual(20, label1.duration())
Example #3
0
 def test_large_numbers_do_not_overflow(self):
     departure_time = 1475530980
     arrival_time = 1475530980
     label = LabelTimeBoardingsAndRoute(
         departure_time=float(departure_time),
         arrival_time_target=float(arrival_time),
         movement_duration=0,
         n_boardings=1,
         first_leg_is_walk=False)
     self.assertEqual(departure_time, label.departure_time)
     self.assertEqual(arrival_time, label.arrival_time_target)
Example #4
0
 def test_various_dominates(self):
     labela = LabelTimeBoardingsAndRoute(departure_time=1481520618, arrival_time_target=1481521300, n_boardings=1,
                                         movement_duration=681, first_leg_is_walk=True)
     labelb = LabelTimeBoardingsAndRoute(departure_time=1481520618, arrival_time_target=1481521215, n_boardings=1,
                                         movement_duration=597, first_leg_is_walk=True)
     self.assertTrue(labelb.dominates(labela))
     self.assertFalse(labela.dominates(labelb))
Example #5
0
 def test_dominates_ignoring_dep_time_arrival_time(self):
     labela = LabelTimeBoardingsAndRoute(departure_time=1, arrival_time_target=9, movement_duration=1, n_boardings=1,
                                         first_leg_is_walk=False)
     labelb = LabelTimeBoardingsAndRoute(departure_time=1, arrival_time_target=10, movement_duration=1, n_boardings=1,
                                         first_leg_is_walk=False)
     self.assertFalse(labelb.dominates_ignoring_dep_time(labela))
     self.assertTrue(labela.dominates_ignoring_dep_time(labelb))
Example #6
0
 def test_dominates_earlier_departure_time(self):
     label2 = LabelTimeBoardingsAndRoute(departure_time=1,
                                         arrival_time_target=10,
                                         movement_duration=0,
                                         n_boardings=1,
                                         first_leg_is_walk=False)
     label5 = LabelTimeBoardingsAndRoute(departure_time=0,
                                         arrival_time_target=10,
                                         movement_duration=0,
                                         n_boardings=1,
                                         first_leg_is_walk=False)
     self.assertTrue(label2.dominates(label5))
     self.assertFalse(label5.dominates(label2))
Example #7
0
 def test_dominates_less_movement_duration_when_departure_time_not_the_same(
         self):
     labela = LabelTimeBoardingsAndRoute(departure_time=4,
                                         arrival_time_target=10,
                                         movement_duration=1,
                                         n_boardings=1,
                                         first_leg_is_walk=False)
     labelb = LabelTimeBoardingsAndRoute(departure_time=1,
                                         arrival_time_target=10,
                                         movement_duration=0,
                                         n_boardings=1,
                                         first_leg_is_walk=False)
     self.assertFalse(labelb.dominates(labela))
     self.assertTrue(labela.dominates(labelb))