Esempio n. 1
0
 def test_entails(self):
     ind1 = Independencies([['A', 'B'], ['C', 'D'], 'E'])
     ind2 = Independencies(['A', 'C', 'E'])
     self.assertTrue(ind1.entails(ind2))
     self.assertFalse(ind2.entails(ind1))
     ind3 = Independencies(('W', ['X', 'Y', 'Z']))
     self.assertTrue(ind3.entails(ind3.closure()))
     self.assertTrue(ind3.closure().entails(ind3))
Esempio n. 2
0
 def test_closure(self):
     ind1 = Independencies(('A', ['B', 'C'], 'D'))
     self.assertEqual(
         ind1.closure(),
         Independencies(('A', ['B', 'C'], 'D'), ('A', 'B', ['C', 'D']),
                        ('A', 'C', ['B', 'D']), ('A', 'B', 'D'),
                        ('A', 'C', 'D')))
     ind2 = Independencies(('W', ['X', 'Y', 'Z']))
     self.assertEqual(
         ind2.closure(),
         Independencies(('W', 'Y'), ('W', 'Y', 'X'), ('W', 'Y', 'Z'),
                        ('W', 'Y', ['X', 'Z']), ('W', ['Y', 'X']),
                        ('W', 'X', ['Y', 'Z']), ('W', ['X', 'Z'], 'Y'),
                        ('W', 'X'), ('W', ['X', 'Z']),
                        ('W', ['Y', 'Z'], 'X'), ('W', ['Y', 'X', 'Z']),
                        ('W', 'X', 'Z'), ('W', ['Y', 'Z']), ('W', 'Z', 'X'),
                        ('W', 'Z'), ('W', ['Y', 'X'], 'Z'), ('W', 'X', 'Y'),
                        ('W', 'Z', ['Y', 'X']), ('W', 'Z', 'Y')))
     ind3 = Independencies(('c', 'a', ['b', 'e', 'd']),
                           (['e', 'c'], 'b', ['a', 'd']),
                           (['b', 'd'], 'e', 'a'), ('e', ['b', 'd'], 'c'),
                           ('e', ['b', 'c'], 'd'), (['e', 'c'], 'a', 'b'))
     self.assertEqual(len(ind3.closure().get_assertions()), 78)