def test_ex_compute_prob_top_100_from_10_return_15(self): """Test ex compute prob top 100 from 10 return 15.""" for stats in examples.compute_probabilities(100, 10): if stats['count'] == 15: result = stats['p'] break expected = 0.5929 self.assertAlmostEqual(result, expected, 3)
def test_ex_compute_prob_with_boundary_threshold(self): """Test ex compute prob with boundary threshold.""" result = None for stats in examples.compute_probabilities(5, 2, 1): result = stats self.assertTrue(result is None)
def test_ex_compute_prob_and_use_threshold(self): """Test ex compute prob and use threshold.""" for stats in examples.compute_probabilities(5, 2, 4): result = stats self.assertEqual(result['count'], 4) self.assertAlmostEqual(result['p'], 0.375, 3)