Beispiel #1
0
    def test_bijection(self):
        self.assertTrue(is_bijective(Set()))
        self.assertIs(is_bijective(Set('a', 'b', 'c')), Undef())
        f = is_bijective(basic_sets['left func'])
        self.assertTrue(f)
        f = is_bijective(basic_sets['not left func'])
        self.assertFalse(f)
        f = is_bijective(basic_sets['not right func'])
        self.assertFalse(f)
        f = is_bijective(basic_clans['left func'])
        self.assertTrue(f)
        f = is_bijective(basic_clans['not right func'])
        self.assertFalse(f)
        f = is_bijective(basic_hordes['left func'])
        self.assertTrue(f)
        f = is_bijective(basic_hordes['not right func'])
        self.assertFalse(f)

        s = basic_sets['left func']
        self.assertEqual(s.cached_functional, CacheStatus.IS)
        self.assertEqual(s.cached_right_functional, CacheStatus.IS)
        s = basic_sets['not left func']
        self.assertEqual(s.cached_functional, CacheStatus.IS_NOT)
        # The right flags aren't checked if left fails
        self.assertEqual(s.cached_right_functional, CacheStatus.UNKNOWN)
    def test_bijection(self):
        self.assertTrue(is_bijective(Set()))
        self.assertIs(is_bijective(Set("a", "b", "c")), Undef())
        f = is_bijective(basic_sets["left func"])
        self.assertTrue(f)
        f = is_bijective(basic_sets["not left func"])
        self.assertFalse(f)
        f = is_bijective(basic_sets["not right func"])
        self.assertFalse(f)
        f = is_bijective(basic_clans["left func"])
        self.assertTrue(f)
        f = is_bijective(basic_clans["not right func"])
        self.assertFalse(f)
        f = is_bijective(basic_hordes["left func"])
        self.assertTrue(f)
        f = is_bijective(basic_hordes["not right func"])
        self.assertFalse(f)

        s = basic_sets["left func"]
        self.assertEqual(s.cached_functional, CacheStatus.IS)
        self.assertEqual(s.cached_right_functional, CacheStatus.IS)
        s = basic_sets["not left func"]
        self.assertEqual(s.cached_functional, CacheStatus.IS_NOT)
        # The right flags aren't checked if left fails
        self.assertEqual(s.cached_right_functional, CacheStatus.UNKNOWN)
 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())
 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())
Beispiel #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())