Esempio n. 1
0
    def test_tick_bounds_error(self):
        d = Dist(2)
        with self.assertRaises(IndexError):
            d.tick(-1)

        with self.assertRaises(IndexError):
            d.tick(3)
Esempio n. 2
0
    def test_tick_bounds_error(self):
        d = Dist(2)
        with self.assertRaises(IndexError):
            d.tick(-1)

        with self.assertRaises(IndexError):
            d.tick(3)
Esempio n. 3
0
    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)))
Esempio n. 4
0
    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)))
Esempio n. 5
0
    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())
Esempio n. 6
0
    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())