def test_tick_bounds_error(self): d = Dist(2) with self.assertRaises(IndexError): d.tick(-1) with self.assertRaises(IndexError): d.tick(3)
def test_relative_entropy_sizes(self): p = Dist(5) p.tick(0) q = Dist(4) p.tick(1) self.assertTrue(isnan(relative_entropy(p, q))) self.assertTrue(isnan(relative_entropy(q, p)))
def test_relative_entropy_invalid(self): p = Dist(5) q = Dist(5) self.assertTrue(isnan(relative_entropy(p, q))) p.tick(0) self.assertTrue(isnan(relative_entropy(p, q))) self.assertTrue(isnan(relative_entropy(q, p)))
def test_tick(self): d = Dist(2) self.assertEqual(1, d.tick(0)) self.assertEqual(2, d.tick(0)) self.assertEqual(2, d.counts()) self.assertTrue(d.valid())