def test_absolute_threshold_all_on_plateau(self): t = [0, 1, 2, 3] y = [5, 5, 5, 5] sp = BooleanTimeSeries.absolute_threshold(t, y, 5) self.assertEqual([0], sp.t) self.assertEqual([False], sp.y) self.assertEqual(3, sp.end)
def test_absolute_threshold_switch_on_threshold(self): x = [0, 1, 2] y = [10, 5, 0] sp = BooleanTimeSeries.absolute_threshold(x, y, 5) self.assertEqual([0, 1], sp.t) self.assertEqual([True, False], sp.y) self.assertEqual(2, sp.end)
def test_absolute_threshold_start_with_double_plateau(self): x = [0, 1, 2, 3, 4] y = [5, 5, 0, 10, 0] sp = BooleanTimeSeries.absolute_threshold(x, y, 5) self.assertEqual([0, 2.5, 3.5], sp.t) self.assertEqual([False, True, False], sp.y) self.assertEqual(4, sp.end)
def test_absolute_threshold_switch_on_multiple_plateau(self): x = [0, 1, 2, 3, 4] y = [10, 5, 5, 0, 1] sp = BooleanTimeSeries.absolute_threshold(x, y, 5) self.assertEqual([0, 1.5], sp.t) self.assertEqual([True, False], sp.y) self.assertEqual(4, sp.end)
def test_absolute_threshold_touch_threshold_from_above(self): x = [0, 1, 2] y = [10, 5, 10] sp = BooleanTimeSeries.absolute_threshold(x, y, 5) self.assertEqual([0], sp.t) self.assertEqual([True], sp.y) self.assertEqual(2, sp.end)
def test_absolute_threshold_touch_threshold_from_below(self): x = [0, 1, 2] y = [0, 5, 0] sp = BooleanTimeSeries.absolute_threshold(x, y, 5) self.assertEqual([0], sp.t) self.assertEqual([False], sp.y) self.assertEqual(2, sp.end)
def test_absolute_threshold(self): x = [0, 1, 2] y = [0, 10, 0] sp = BooleanTimeSeries.absolute_threshold(x, y, 5) self.assertEqual([0, 0.5, 1.5], sp.t) self.assertEqual([False, True, False], sp.y) self.assertEqual(2, sp.end)