def test_flags_cache(self):
        c = Couplet(1, 2)
        self.assertEqual(c.cached_relation, CacheStatus.IS_NOT)
        self.assertEqual(c.cached_clan, CacheStatus.IS_NOT)
        self.assertEqual(c.cached_multiclan, CacheStatus.IS_NOT)
        self.assertEqual(c.cached_functional, CacheStatus.N_A)
        self.assertEqual(c.cached_right_functional, CacheStatus.N_A)
        self.assertEqual(c.cached_regular, CacheStatus.N_A)
        self.assertEqual(c.cached_reflexive, CacheStatus.UNKNOWN)
        self.assertEqual(c.cached_symmetric, CacheStatus.N_A)
        self.assertEqual(c.cached_transitive, CacheStatus.N_A)

        is_reflexive(c)
        self.assertEqual(c.cached_reflexive, CacheStatus.IS_NOT)

        self.assertRaises(AssertionError, lambda: c.cache_relation(CacheStatus.IS))
        self.assertRaises(AssertionError, lambda: c.cache_clan(CacheStatus.IS))
        self.assertRaises(AssertionError, lambda: c.cache_multiclan(CacheStatus.IS))
        self.assertRaises(AssertionError, lambda: c.cache_reflexive(CacheStatus.IS))

        self.assertRaises(Exception, lambda: c.cache_transitive(CacheStatus.IS_NOT))
        self.assertRaises(Exception, lambda: c.cache_functional(CacheStatus.IS_NOT))
        self.assertRaises(Exception, lambda: c.cache_right_functional(CacheStatus.IS_NOT))
        self.assertRaises(Exception, lambda: c.cache_regular(CacheStatus.IS_NOT))
        self.assertRaises(Exception, lambda: c.cache_symmetric(CacheStatus.IS_NOT))
        self.assertRaises(Exception, lambda: c.cache_transitive(CacheStatus.IS_NOT))
    def test_flags_cache(self):
        c = Couplet(1, 2)
        self.assertEqual(c.cached_relation, CacheStatus.IS_NOT)
        self.assertEqual(c.cached_clan, CacheStatus.IS_NOT)
        self.assertEqual(c.cached_multiclan, CacheStatus.IS_NOT)
        self.assertEqual(c.cached_functional, CacheStatus.N_A)
        self.assertEqual(c.cached_right_functional, CacheStatus.N_A)
        self.assertEqual(c.cached_regular, CacheStatus.N_A)
        self.assertEqual(c.cached_reflexive, CacheStatus.UNKNOWN)
        self.assertEqual(c.cached_symmetric, CacheStatus.N_A)
        self.assertEqual(c.cached_transitive, CacheStatus.N_A)

        is_reflexive(c)
        self.assertEqual(c.cached_reflexive, CacheStatus.IS_NOT)

        self.assertRaises(AssertionError,
                          lambda: c.cache_relation(CacheStatus.IS))
        self.assertRaises(AssertionError, lambda: c.cache_clan(CacheStatus.IS))
        self.assertRaises(AssertionError,
                          lambda: c.cache_multiclan(CacheStatus.IS))
        self.assertRaises(AssertionError,
                          lambda: c.cache_reflexive(CacheStatus.IS))

        self.assertRaises(Exception,
                          lambda: c.cache_transitive(CacheStatus.IS_NOT))
        self.assertRaises(Exception,
                          lambda: c.cache_functional(CacheStatus.IS_NOT))
        self.assertRaises(Exception,
                          lambda: c.cache_right_functional(CacheStatus.IS_NOT))
        self.assertRaises(Exception,
                          lambda: c.cache_regular(CacheStatus.IS_NOT))
        self.assertRaises(Exception,
                          lambda: c.cache_symmetric(CacheStatus.IS_NOT))
        self.assertRaises(Exception,
                          lambda: c.cache_transitive(CacheStatus.IS_NOT))
 def test_properties(self):
     def _test_undef(cc):
         self.assertIs(cc.get_left_set(), Undef())
         self.assertIs(is_functional(cc), Undef())
         self.assertIs(cc.get_right_set(), Undef())
         self.assertIs(is_right_functional(cc), Undef())
         self.assertIs(is_bijective(cc), Undef())
         self.assertIs(is_transitive(cc), Undef())
         self.assertIs(is_equivalence_relation(cc), Undef())
     c = Couplet(1, 2)
     _test_undef(c)
     self.assertFalse(is_reflexive(c))
     c = Couplet(1)
     _test_undef(c)
     self.assertTrue(is_reflexive(c))
Пример #4
0
 def test_properties(self):
     def _test_undef(cc):
         self.assertIs(cc.get_left_set(), Undef())
         self.assertIs(is_functional(cc), Undef())
         self.assertIs(cc.get_right_set(), Undef())
         self.assertIs(is_right_functional(cc), Undef())
         self.assertIs(is_bijective(cc), Undef())
         self.assertIs(is_transitive(cc), Undef())
         self.assertIs(is_equivalence_relation(cc), Undef())
     c = Couplet(1, 2)
     _test_undef(c)
     self.assertFalse(is_reflexive(c))
     c = Couplet(1)
     _test_undef(c)
     self.assertTrue(is_reflexive(c))
Пример #5
0
 def test_properties(self):
     a = ba['2']
     self.assertIs(a.get_left_set(), Undef())
     self.assertIs(is_functional(a), Undef())
     self.assertIs(a.get_right_set(), Undef())
     self.assertIs(is_right_functional(a), Undef())
     self.assertIs(is_bijective(a), Undef())
     self.assertIs(is_reflexive(a), Undef())
     self.assertIs(is_symmetric(a), Undef())
     self.assertIs(is_transitive(a), Undef())
     self.assertIs(is_equivalence_relation(a), Undef())
 def test_properties(self):
     a = ba['2']
     self.assertIs(a.get_left_set(), Undef())
     self.assertIs(is_functional(a), Undef())
     self.assertIs(a.get_right_set(), Undef())
     self.assertIs(is_right_functional(a), Undef())
     self.assertIs(is_bijective(a), Undef())
     self.assertIs(is_reflexive(a), Undef())
     self.assertIs(is_symmetric(a), Undef())
     self.assertIs(is_transitive(a), Undef())
     self.assertIs(is_equivalence_relation(a), Undef())
Пример #7
0
    def test_reflexive(self):
        self.assertTrue(is_reflexive(Set()))
        self.assertIs(is_reflexive(Set('a', 'b', 'c')), Undef())
        f = is_reflexive(basic_sets['not left func'])
        self.assertFalse(f)
        f = is_reflexive(basic_sets['diagonal'])
        self.assertTrue(f)
        f = is_reflexive(basic_clans['not left func'])
        self.assertFalse(f)
        f = is_reflexive(basic_clans['diagonal'])
        self.assertTrue(f)
        f = is_reflexive(basic_hordes['not left func'])
        self.assertFalse(f)
        f = is_reflexive(basic_hordes['diagonal'])
        self.assertTrue(f)

        s = basic_sets['diagonal']
        self.assertEqual(s.cached_reflexive, CacheStatus.IS)
        s = basic_sets['not left func']
        self.assertEqual(s.cached_reflexive, CacheStatus.IS_NOT)
Пример #8
0
    def test_reflexive(self):
        self.assertTrue(is_reflexive(Set()))
        self.assertIs(is_reflexive(Set("a", "b", "c")), Undef())
        f = is_reflexive(basic_sets["not left func"])
        self.assertFalse(f)
        f = is_reflexive(basic_sets["diagonal"])
        self.assertTrue(f)
        f = is_reflexive(basic_clans["not left func"])
        self.assertFalse(f)
        f = is_reflexive(basic_clans["diagonal"])
        self.assertTrue(f)
        f = is_reflexive(basic_hordes["not left func"])
        self.assertFalse(f)
        f = is_reflexive(basic_hordes["diagonal"])
        self.assertTrue(f)

        s = basic_sets["diagonal"]
        self.assertEqual(s.cached_reflexive, CacheStatus.IS)
        s = basic_sets["not left func"]
        self.assertEqual(s.cached_reflexive, CacheStatus.IS_NOT)
Пример #9
0
    def test_reflexive(self):
        self.assertTrue(is_reflexive(Set()))
        self.assertIs(is_reflexive(Set('a', 'b', 'c')), Undef())
        f = is_reflexive(basic_sets['not left func'])
        self.assertFalse(f)
        f = is_reflexive(basic_sets['diagonal'])
        self.assertTrue(f)
        f = is_reflexive(basic_clans['not left func'])
        self.assertFalse(f)
        f = is_reflexive(basic_clans['diagonal'])
        self.assertTrue(f)
        f = is_reflexive(basic_hordes['not left func'])
        self.assertFalse(f)
        f = is_reflexive(basic_hordes['diagonal'])
        self.assertTrue(f)

        s = basic_sets['diagonal']
        self.assertEqual(s.cached_reflexive, CacheStatus.IS)
        s = basic_sets['not left func']
        self.assertEqual(s.cached_reflexive, CacheStatus.IS_NOT)