Ejemplo n.º 1
0
    def test_guide_coords_x(self):
        v = GlobalSpeedValidator(max_trial_duration=1, origin_coord=0, end_coord=100, show_guide=True, axis=ValidationAxis.x)
        v._guide = DbgGlobalSpeedGuide(v)

        v.reset()
        v.check_xyt(99, 0, .5)
        self.assertEqual((50, 0), v.guide._guide_line.active_stimulus.position)
Ejemplo n.º 2
0
    def test_validate_x_axis(self):
        v = GlobalSpeedValidator(max_trial_duration=1, origin_coord=0, end_coord=100, axis=ValidationAxis.x)
        v.reset()
        self.assertIsNone(v.check_xyt(50, 0, .5))
        self.assertIsNone(v.check_xyt(100, 0, 1))

        v.reset()
        self.assertIsNotNone(v.check_xyt(49, 0, .5))
Ejemplo n.º 3
0
    def test_validate_uninitialized(self):
        v = GlobalSpeedValidator(origin_coord=0, end_coord=100)
        self.assertRaises(trajtracker.InvalidStateError, lambda: v.check_xyt(0, 0, 0))

        v = GlobalSpeedValidator(max_trial_duration=1, end_coord=100)
        self.assertRaises(trajtracker.InvalidStateError, lambda: v.check_xyt(0, 0, 0))

        v = GlobalSpeedValidator(max_trial_duration=1, origin_coord=0)
        self.assertRaises(trajtracker.InvalidStateError, lambda: v.check_xyt(0, 0, 0))
Ejemplo n.º 4
0
    def test_validate_two_milestones(self):
        v = GlobalSpeedValidator(max_trial_duration=6, origin_coord=0, end_coord=100,
                                 milestones=[(.5, .25), (.5, .75)])
        v.reset()
        self.assertIsNone(v.check_xyt(0, 25, 3))
        self.assertIsNone(v.check_xyt(0, 75, 5))
        self.assertIsNone(v.check_xyt(0, 100, 6))

        v.reset()
        self.assertIsNotNone(v.check_xyt(0, 24, 3))
        self.assertIsNotNone(v.check_xyt(0, 74, 5))
        self.assertIsNotNone(v.check_xyt(0, 99, 6))

        self.assertTrue(np.abs(25/3 - v.get_expected_coord_at_time(1)) < .00001)
        self.assertEqual(50, v.get_expected_coord_at_time(4))
Ejemplo n.º 5
0
    def test_validate_move_backwards(self):
        v = GlobalSpeedValidator(max_trial_duration=1, origin_coord=100, end_coord=0)

        self.assertEqual(100, v.get_expected_coord_at_time(0))
        self.assertEqual(90, v.get_expected_coord_at_time(.1))
        self.assertEqual(20, v.get_expected_coord_at_time(.8))
        self.assertEqual(0, v.get_expected_coord_at_time(1))
        self.assertEqual(0, v.get_expected_coord_at_time(9))

        v.reset()
        self.assertIsNone(v.check_xyt(0, 50, .5))
        self.assertIsNone(v.check_xyt(0, 0, 1))

        v.reset()
        self.assertIsNotNone(v.check_xyt(0, 51, .5))

        v.reset()
        self.assertIsNotNone(v.check_xyt(0, 1, 1))
Ejemplo n.º 6
0
    def test_validate_one_milestone(self):
        v = GlobalSpeedValidator(max_trial_duration=1, origin_coord=0, end_coord=100)

        self.assertEqual(0, v.get_expected_coord_at_time(0))
        self.assertEqual(10, v.get_expected_coord_at_time(.1))
        self.assertEqual(80, v.get_expected_coord_at_time(.8))
        self.assertEqual(100, v.get_expected_coord_at_time(1))
        self.assertEqual(100, v.get_expected_coord_at_time(9))

        v.reset()
        self.assertIsNone(v.check_xyt(0, 50, .5))
        self.assertIsNone(v.check_xyt(0, 100, 1))

        v.reset()
        self.assertIsNotNone(v.check_xyt(0, 49, .5))

        v.reset()
        self.assertIsNotNone(v.check_xyt(0, 99, 1))
Ejemplo n.º 7
0
    def test_guide_selects_color(self):
        v = GlobalSpeedValidator(max_trial_duration=1, origin_coord=0, end_coord=100, show_guide=True, grace_period=.3)
        v.guide_warning_time_delta = .1
        v._guide = DbgGlobalSpeedGuide(v)

        v.reset()

        v.check_xyt(0, 1, .2)
        self.assertEqual(v.guide.LineMode.Grace, v.guide._guide_line.selected_key)

        v.check_xyt(0, 1, .3)
        self.assertEqual(v.guide.LineMode.Grace, v.guide._guide_line.selected_key)

        v.check_xyt(0, 61, .5)
        self.assertEqual(v.guide.LineMode.OK, v.guide._guide_line.selected_key)

        v.check_xyt(0, 55, .5)
        self.assertEqual(v.guide.LineMode.Error, v.guide._guide_line.selected_key)
Ejemplo n.º 8
0
 def test_validate_grace_period(self):
     v = GlobalSpeedValidator(max_trial_duration=10, origin_coord=0, end_coord=100, grace_period=3)
     v.reset()
     self.assertIsNone(v.check_xyt(0, 1, 2))
     self.assertIsNone(v.check_xyt(0, 1, 3))
     self.assertIsNotNone(v.check_xyt(0, 1, 3.0001))
Ejemplo n.º 9
0
 def test_disabled(self):
     v = GlobalSpeedValidator(max_trial_duration=1, origin_coord=0, end_coord=100, enabled=False)
     self.assertIsNone(v.check_xyt(0, 49, .5))