def test_last_n_average_threshold_factory(self):
    alg = trivial.last_n_average_threshold_factory(300, 20.0, {'threshold': 0.5, 'n': 2})
    self.assertEqual(alg([]), (False, {}))
    self.assertEqual(alg([0.0, 0.0]), (True, {}))
    self.assertEqual(alg([0.0, 0.4]), (True, {}))
    self.assertEqual(alg([0.0, 0.5]), (True, {}))
    self.assertEqual(alg([0.0, 0.6]), (True, {}))
    self.assertEqual(alg([0.0, 1.0]), (True, {}))
    self.assertEqual(alg([0.2, 1.0]), (False, {}))
    self.assertEqual(alg([0.0, 0.2, 1.0]), (False, {}))
    self.assertEqual(alg([0.0, 1.0, 1.0]), (False, {}))
    self.assertEqual(alg([0.0, 0.6, 0.6]), (False, {}))
    alg = trivial.last_n_average_threshold_factory(300, 20.0, {'threshold': 0.5, 'n': 3})
    self.assertEqual(alg([0.0, 0.6, 0.6]), (True, {}))
def test_last_n_average_threshold_factory(self):
    alg = trivial.last_n_average_threshold_factory(300, 20.0, {'threshold': 0.5, 'n': 2})
    self.assertEqual(alg([]), (False, {}))
    self.assertEqual(alg([0.0, 0.0]), (True, {}))
    self.assertEqual(alg([0.0, 0.4]), (True, {}))
    self.assertEqual(alg([0.0, 0.5]), (True, {}))
    self.assertEqual(alg([0.0, 0.6]), (True, {}))
    self.assertEqual(alg([0.0, 1.0]), (True, {}))
    self.assertEqual(alg([0.2, 1.0]), (False, {}))
    self.assertEqual(alg([0.0, 0.2, 1.0]), (False, {}))
    self.assertEqual(alg([0.0, 1.0, 1.0]), (False, {}))
    self.assertEqual(alg([0.0, 0.6, 0.6]), (False, {}))
    alg = trivial.last_n_average_threshold_factory(300, 20.0, {'threshold': 0.5, 'n': 3})
    self.assertEqual(alg([0.0, 0.6, 0.6]), (True, {}))