def test_intersect(self):
        self._check_wrong_argument_types_binary(intersect)

        result = intersect(_set1, _set2)
        self.assertEqual(result, _set1i2)
        a_c_0 = Set([Set('a'), Set('c'), Set()])
        ci = _extension.binary_extend(_ab_c, _ac_a, intersect)
        self.assertEqual(ci, a_c_0)
Esempio n. 2
0
    def test_intersect(self):
        self._check_wrong_argument_types_binary(intersect)

        result = intersect(_set1, _set2)
        self.assertEqual(result, _set1i2)
        a_c_0 = Set(Set('a'), Set('c'), Set())
        ci = _extension.binary_extend(_ab_c, _ac_a, intersect)
        self.assertEqual(ci, a_c_0)
Esempio n. 3
0
# sets are unordered, they do not support random access (no bracket operator).
nums = Set(1, 2, 3, 4, 5)
for elem in nums:
    print(elem, " ")
print(1 in nums)
print(7 in nums)

# Sets can be unioned, intersected, set-minused. Relations such as is_subset and is_superset are
# defined.
a = Set(1, 2)
b = Set(2, 3)

import algebraixlib.algebras.sets as sets

print("union(a, b) = {}".format(sets.union(a, b)))
print("intersect(a, b) = {}".format(sets.intersect(a, b)))
print("minus(a, b) = {}".format(sets.minus(a, b)))
print("is_subset(a, b) = {}".format(sets.is_subset_of(a, b)))
print("is_superset(a, {{1}}) = {}".format(sets.is_superset_of(a, Set(1))))

# We can use a Couplet to model a single truth, such as 'blue'^'sky' or 'jeff'^'name'. By collecting
# multiple Couplets together in a set, we form a mathematical model of a data record. This data
# structure, called a binary relation (abbreviated from hereon as simply 'relation'), is the
# fundamental data type in a Data Algebra program.
record_relation = Set(Couplet('id', 123), Couplet('name', 'jeff'), Couplet('loves', 'math'),
                      Couplet('loves', 'code'))
print(record_relation)

# Some relations, specify a function from left to right. This is the case when every left
# value maps to exactly one right value. Such a relation is called "left functional".
# Likewise, a relation can be said to be "right functional" when every right value maps
Esempio n. 4
0
# sets are unordered, they do not support random access (no bracket operator).
nums = Set(1, 2, 3, 4, 5)
for elem in nums:
    print(elem, " ")
print(1 in nums)
print(7 in nums)

# Sets can be unioned, intersected, set-minused. Relations such as is_subset and is_superset are
# defined.
a = Set(1, 2)
b = Set(2, 3)

import algebraixlib.algebras.sets as sets

print("union(a, b) = {}".format(sets.union(a, b)))
print("intersect(a, b) = {}".format(sets.intersect(a, b)))
print("minus(a, b) = {}".format(sets.minus(a, b)))
print("is_subset(a, b) = {}".format(sets.is_subset_of(a, b)))
print("is_superset(a, {{1}}) = {}".format(sets.is_superset_of(a, Set(1))))

# We can use a Couplet to model a single truth, such as 'sky'->'blue' or 'name'->'jeff'. By
# collecting multiple Couplets together in a set, we form a mathematical model of a data record.
# This data structure, called a binary relation (abbreviated from hereon as simply 'relation'), is
# the fundamental data type in a Data Algebra program.
record_relation = Set(Couplet('id', 123), Couplet('name', 'jeff'),
                      Couplet('loves', 'math'), Couplet('loves', 'code'))
print(record_relation)

# Some relations, specify a function from left to right. This is the case when every left
# value maps to exactly one right value. Such a relation is called "left functional".
# Likewise, a relation can be said to be "right functional" when every right value maps