def test_compose(self):
     """Basic tests of clans.compose()."""
     self._check_wrong_argument_types_binary(compose)
     # Compose.
     result = compose(ac['clan1'], ac['clan2'])
     self.assertEqual(result, ac['clan1comp2'])
     result = compose(ac['clan2'], ac['clan1'])
     expected = ac['clan2comp1']
     self.assertEqual(result, expected)
 def test_compose(self):
     """Basic tests of clans.compose()."""
     self._check_wrong_argument_types_binary(compose)
     # Compose.
     result = compose(ac['clan1'], ac['clan2'])
     self.assertEqual(result, ac['clan1comp2'])
     result = compose(ac['clan2'], ac['clan1'])
     expected = ac['clan2comp1']
     self.assertEqual(result, expected)
Beispiel #3
0
# 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))
print('=> EVALUATES TO ' + str(simple_compose_1))

print("multiclan's compose applies a cross compose of the relations in each sides multiclan, "
      "the multiplicity is the product of each sides multiplicity.\n")

simple_compose_2 = _multiclans.compose(mc_2, mc_1)

print(str(mc_2) + ' COMPOSE ' + str(mc_1))
print('=> EVALUATES TO ' + str(simple_compose_2))

print("multiclan's compose can result in relation compositions such that two different operations"
      "yield the same result.  For multiclans operations these same results are summed together.\n")
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))
print('=> EVALUATES TO ' + str(simple_compose_1))

print(
    "multiclan's compose applies a cross compose of the relations in each sides multiclan, "
    "the multiplicity is the product of each sides multiplicity.\n")

simple_compose_2 = _multiclans.compose(mc_2, mc_1)

print(str(mc_2) + ' COMPOSE ' + str(mc_1))
print('=> EVALUATES TO ' + str(simple_compose_2))

print(
    "multiclan's compose can result in relation compositions such that two different operations"