def test_transpose(self):
     """Basic tests of clans.transpose()."""
     self._check_wrong_argument_type_unary(transpose)
     # Transpose.
     result = transpose(ac['clan1'])
     self.assertEqual(result, ac['clan1transp'])
Exemple #2
0
# Setting up multiclan relations
rel_1 = _mo.Set(_mo.Couplet('x', 'y'), _mo.Couplet('w', 'y'))
rel_2 = _mo.Set(_mo.Couplet('a', 'x'), _mo.Couplet('b', 'w'))
rel_3 = _mo.Set(_mo.Couplet('x', 'z'), _mo.Couplet('v', 'y'))
rel_4 = _mo.Set(_mo.Couplet('c', 'z'), _mo.Couplet('a', 'v'))
rel_5 = _mo.Set(_mo.Couplet('b', 'w'), _mo.Couplet('w', 'y'))
rel_6 = _mo.Set(_mo.Couplet('a', 'x'), _mo.Couplet('x', 'y'))

# Creating multiclans (multisets of relations)
mc_1 = _mo.Multiset({rel_1: 2, rel_3: 3})
mc_2 = _mo.Multiset({rel_2: 5, rel_4: 1})
mc_3 = _mo.Multiset({rel_1: 2, rel_6: 7})
mc_4 = _mo.Multiset({rel_2: 5, rel_5: 11})

# Multiset Transpose Operation Example
simple_transpose = _multiclans.transpose(mc_1)

print('TRANSPOSE ' + str(mc_1))
print('=> EVALUATES TO ' + str(simple_transpose))

mc_tmp = _mo.Multiset(
    {_mo.Set(_mo.Couplet('y', 'x'), _mo.Couplet('y', 'w')): 2,
     _mo.Set(_mo.Couplet('z', 'x'), _mo.Couplet('y', 'v')): 3})
if mc_tmp == simple_transpose:
    print("multiclan's transpose swaps the left and right values of the relations, "
          "leaving multiplicity to be the same.\n")

# Multiset Compose Operation Example
simple_compose_1 = _multiclans.compose(mc_1, mc_2)

print(str(mc_1) + ' COMPOSE ' + str(mc_2))
 def test_transpose(self):
     """Basic tests of clans.transpose()."""
     self._check_wrong_argument_type_unary(transpose)
     # Transpose.
     result = transpose(ac['clan1'])
     self.assertEqual(result, ac['clan1transp'])
# Setting up multiclan relations
rel_1 = _mo.Set(_mo.Couplet('x', 'y'), _mo.Couplet('w', 'y'))
rel_2 = _mo.Set(_mo.Couplet('a', 'x'), _mo.Couplet('b', 'w'))
rel_3 = _mo.Set(_mo.Couplet('x', 'z'), _mo.Couplet('v', 'y'))
rel_4 = _mo.Set(_mo.Couplet('c', 'z'), _mo.Couplet('a', 'v'))
rel_5 = _mo.Set(_mo.Couplet('b', 'w'), _mo.Couplet('w', 'y'))
rel_6 = _mo.Set(_mo.Couplet('a', 'x'), _mo.Couplet('x', 'y'))

# Creating multiclans (multisets of relations)
mc_1 = _mo.Multiset({rel_1: 2, rel_3: 3})
mc_2 = _mo.Multiset({rel_2: 5, rel_4: 1})
mc_3 = _mo.Multiset({rel_1: 2, rel_6: 7})
mc_4 = _mo.Multiset({rel_2: 5, rel_5: 11})

# Multiset Transpose Operation Example
simple_transpose = _multiclans.transpose(mc_1)

print('TRANSPOSE ' + str(mc_1))
print('=> EVALUATES TO ' + str(simple_transpose))

mc_tmp = _mo.Multiset({
    _mo.Set(_mo.Couplet('y', 'x'), _mo.Couplet('y', 'w')): 2,
    _mo.Set(_mo.Couplet('z', 'x'), _mo.Couplet('y', 'v')): 3
})
if mc_tmp == simple_transpose:
    print(
        "multiclan's transpose swaps the left and right values of the relations, "
        "leaving multiplicity to be the same.\n")

# Multiset Compose Operation Example
simple_compose_1 = _multiclans.compose(mc_1, mc_2)