def test_superstrict(self): self._check_wrong_argument_types_binary(superstrict) result1 = superstrict(_set1u2, _set1) self.assertEqual(result1, _set1u2) result2 = superstrict(_set2, _set1) self.assertIs(result2, Undef())
mariposa,Spanish,butterfly """ # Tables can be modeled as sets of binary relations, which we call clans. from io import StringIO from algebraixlib.io.csv import import_csv file = StringIO(vocab_csv) vocab_clan = import_csv(file) print("vocab_clan:", vocab_clan) # Superstriction(A, B) is a partial binary operation on sets. It is defined as A if A is a superset # of B, otherwise it is undefined. hello_relation = Set(Couplet('word', 'hello'), Couplet('language', 'English'), Couplet('meaning', 'salutation')) super_pos = sets.superstrict(hello_relation, Set(Couplet('language', 'English'))) super_neg = sets.superstrict(hello_relation, Set(Couplet('language', 'Mandarin'))) print(super_pos) print(super_neg) # By extending superstriction to clans, which are sets of sets (of Couplets), we can define a helpful # mechanism to restrict vocab_clan to only those relations that contain particular values. import algebraixlib.algebras.clans as clans salutation_records_clan = clans.superstrict(vocab_clan, Set(Set(Couplet('meaning', 'salutation')))) earth_records_clan = clans.superstrict(vocab_clan, Set(Set(Couplet('meaning', 'earth')))) print("salutation_records_clan:", salutation_records_clan) print("earth_records_clan:", earth_records_clan) # By choosing an appropriate right-hand argument, our extended composition operation from earlier can # model projection. words_langs_clan = Set(Set(Couplet('word', 'word'), Couplet('language', 'language')))
mariposa,Spanish,butterfly """ # Tables can be modeled as sets of binary relations, which we call clans. from io import StringIO from algebraixlib.io.csv import import_csv file = StringIO(vocab_csv) vocab_clan = import_csv(file) print("vocab_clan:", vocab_clan) # Superstriction(A, B) is a partial binary operation on sets. It is defined as A if A is a superset # of B, otherwise it is undefined. hello_relation = Set(Couplet('word', 'hello'), Couplet('language', 'English'), Couplet('meaning', 'salutation')) super_pos = sets.superstrict(hello_relation, Set(Couplet('language', 'English'))) super_neg = sets.superstrict(hello_relation, Set(Couplet('language', 'Mandarin'))) print(super_pos) print(super_neg) # By extending superstriction to clans, which are sets of sets (of Couplets), we can define a # helpful mechanism to restrict vocab_clan to only those relations that contain particular values. import algebraixlib.algebras.clans as clans salutation_records_clan = clans.superstrict( vocab_clan, Set(Set(Couplet('meaning', 'salutation')))) earth_records_clan = clans.superstrict(vocab_clan, Set(Set(Couplet('meaning', 'earth')))) print("salutation_records_clan:", salutation_records_clan) print("earth_records_clan:", earth_records_clan)