def test_metadata(self):
     self.assertEqual(
         get_ground_set(),
         PowerSet(CartesianProduct(GenesisSetM(), GenesisSetN())))
     self.assertEqual(
         get_absolute_ground_set(),
         PowerSet(CartesianProduct(GenesisSetA(), GenesisSetN())))
     self.assertEqual(get_name(), 'Multisets(M): P(M x N)')
Ejemplo n.º 2
0
 def test_complex_structures(self):
     """Test more complex structures and their subset relationships."""
     # DA-36
     # P((A x P(A x P((A x P(A x A)) U (A x P(A x P(A))) U (A x A)))) U (A x A))
     s1 = PowerSet(
         Union([
             CartesianProduct(
                 GenesisSetA(),
                 PowerSet(
                     CartesianProduct(
                         GenesisSetA(),
                         PowerSet(
                             Union([
                                 CartesianProduct(
                                     GenesisSetA(),
                                     PowerSet(
                                         CartesianProduct(
                                             GenesisSetA(),
                                             GenesisSetA()))),
                                 CartesianProduct(
                                     GenesisSetA(),
                                     PowerSet(
                                         CartesianProduct(
                                             GenesisSetA(),
                                             PowerSet(GenesisSetA())))),
                                 CartesianProduct(GenesisSetA(),
                                                  GenesisSetA())
                             ]))))),
             CartesianProduct(GenesisSetA(), GenesisSetA())
         ]))
     s2 = PowerSet(CartesianProduct(GenesisSetM(), GenesisSetM()))
     self.assertTrue(s1.is_subset(s2))
Ejemplo n.º 3
0
 def test_complex_structures(self):
     """Test more complex structures and their subset relationships."""
     # DA-36
     # P((A x P(A x P((A x P(A x A)) U (A x P(A x P(A))) U (A x A)))) U (A x A))
     s1 = PowerSet(
         Union([
             CartesianProduct(
                 GenesisSetA(),
                 PowerSet(
                     CartesianProduct(
                         GenesisSetA(),
                         PowerSet(
                             Union([
                                 CartesianProduct(
                                     GenesisSetA(),
                                     PowerSet(
                                         CartesianProduct(GenesisSetA(), GenesisSetA())
                                     )
                                 ),
                                 CartesianProduct(
                                     GenesisSetA(),
                                     PowerSet(
                                         CartesianProduct(
                                             GenesisSetA(),
                                             PowerSet(GenesisSetA())
                                         )
                                     )
                                 ),
                                 CartesianProduct(GenesisSetA(), GenesisSetA())
                             ])
                         )
                     )
                 )
             ),
             CartesianProduct(GenesisSetA(), GenesisSetA())
         ])
     )
     s2 = PowerSet(CartesianProduct(GenesisSetM(), GenesisSetM()))
     self.assertTrue(s1.is_subset(s2))
    def test_multiset_with_one_empty_element(self):
        m = Multiset(Set())
        self.assertEqual(m.cardinality, 1)

        m_repr = repr(m)
        m_str = str(m)

        self.assertEqual(m_repr, "Multiset({Set(): 1})")
        self.assertEqual(m_str, "[{}:1]")
        self.assertEqual(m.get_multiplicity(Set()), 1)
        self.assertEqual(m.get_multiplicity(Atom('b')), 0)
        m_struct = m.get_ground_set()
        m_expected_struct = PowerSet(
            CartesianProduct(Structure(), GenesisSetN()))
        self.assertEqual(m_struct, m_expected_struct)

        import algebraixlib.algebras.multiclans as _multiclans
        self.assertTrue(_multiclans.is_member(m))
        self.assertTrue(_multiclans.is_absolute_member(m))
Ejemplo n.º 5
0
    is_reflexive, is_symmetric, is_transitive, is_equivalence_relation, is_regular
import algebraixlib.algebras.relations as relations
import algebraixlib.algebras.sets as sets
from algebraixlib.mathobjects import Atom, Couplet, MathObject, Set
from algebraixlib.mathobjects.utils import CacheStatus
from algebraixlib.structure import CartesianProduct, GenesisSetA, PowerSet, Structure
from algebraixlib.undef import Undef

# noinspection PyProtectedMember
from algebraixlib.io.csv import _convert_clan_to_list_of_dicts, export_csv
# noinspection PyUnresolvedReferences
from data_mathobjects import basic_sets, basic_clans, algebra_clans, basic_hordes


# Ground set structures for the basic_sets.
_atom_set_struct = PowerSet(GenesisSetA())
_relation_struct = PowerSet(CartesianProduct(GenesisSetA(), GenesisSetA()))
_basic_sets_structs = {
    'empty': Structure(),
    'contains empty': PowerSet(Structure()),
    'num in dict': _atom_set_struct,
    'str in array': _atom_set_struct,
    'single num': _atom_set_struct,
    'single Coupl': _relation_struct,
    'left func': _relation_struct,
    'left func/lefts': _atom_set_struct,
    'left func/rights': _atom_set_struct,
    'not left func': _relation_struct,
    'not right func': _relation_struct,
    'diagonal': _relation_struct,
}
Ejemplo n.º 6
0
 def test_metadata(self):
     self.assertEqual(get_ground_set(), PowerSet(GenesisSetM()))
     self.assertEqual(get_absolute_ground_set(), PowerSet(GenesisSetA()))
     self.assertEqual(get_name(), 'Sets(M): P(M)')
Ejemplo n.º 7
0
                Union([
                    Union([Union([GenesisSetA()]),
                           GenesisSetM()]), basic_cps['AxM']
                ]),
            ]
        },
        'AU(AxA)': {
            'iterable': [Union([GenesisSetA()]), basic_cps['AxA']]
        },
    }.items()
}
_print_object_collection('basic_unions')

#: Basic PowerSet instances.
basic_pss = {
    key: create_test_object(PowerSet(**val), key, val)
    for key, val in {
        'A': {
            'elements_struct': GenesisSetA()
        },
        'M': {
            'elements_struct': GenesisSetM()
        },
        'AxA': {
            'elements_struct': basic_cps['AxA']
        },
        'MxM': {
            'elements_struct': basic_cps['MxM']
        },
        'P(AxA)': {
            'elements_struct': PowerSet(basic_cps['AxA'])
import os
import unittest

from algebraixlib.algebras.properties import is_functional, is_right_functional, is_bijective, \
    is_reflexive, is_transitive, is_equivalence_relation
from algebraixlib.mathobjects import Atom, CacheStatus, Couplet, MathObject, Set
from algebraixlib.structure import CartesianProduct, GenesisSetA, PowerSet
from algebraixlib.undef import Undef

# noinspection PyUnresolvedReferences
from data_mathobjects import basic_couplets

# Ground set structures for the basic_couplets.
_basic_couplet_struct = CartesianProduct(GenesisSetA(), GenesisSetA())
_complex_couplet_struct = CartesianProduct(_basic_couplet_struct,
                                           PowerSet(GenesisSetA()))
_basic_couplets_structs = {
    '3x2': _basic_couplet_struct,
    "'5'x'4'": _basic_couplet_struct,
    "'7'x6": _basic_couplet_struct,
    'Coupl x Set': _complex_couplet_struct
}


class CoupletTest(unittest.TestCase):
    """Test the Couplet class."""

    print_examples = False

    def test_Couplet(self):
        """Create various forms of Couplets."""
#
# You should have received a copy of the GNU Lesser General Public License along with algebraixlib.
# If not, see <http://www.gnu.org/licenses/>.
# --------------------------------------------------------------------------------------------------
import inspect
import os
import unittest

import collections as _collections

from algebraixlib.mathobjects import Atom, CacheStatus, Couplet, Multiset, Set
from algebraixlib.structure import CartesianProduct, GenesisSetN, GenesisSetA, PowerSet, Structure
from algebraixlib.undef import Undef

# Ground set structures for the basic_sets.
_atom_multiset_struct = PowerSet(CartesianProduct(GenesisSetA(),
                                                  GenesisSetN()))


class MultisetTest(unittest.TestCase):
    """Test the Set class."""

    print_examples = False

    #     def test_Multiset(self):
    #         """Create various forms of Sets."""
    #         if self.print_examples:
    #             print('(printing examples)')  # Make 'nosetests -s' more readable.
    #         for test_set_name in basic_multisets.keys():
    #             self._multiset_assert(test_set_name)
    #         self.assertEqual("{}", str(Multiset()))
    #         self.assertTrue(Multiset(1) < Multiset(2))
Ejemplo n.º 10
0
import unittest

from algebraixlib.algebras.properties import is_functional, is_right_functional, is_bijective, \
    is_reflexive, is_transitive, is_equivalence_relation
from algebraixlib.mathobjects import Atom, Couplet, MathObject, Multiset, Set
from algebraixlib.cache_status import CacheStatus
from algebraixlib.structure import CartesianProduct, GenesisSetA, PowerSet
from algebraixlib.undef import Undef

# noinspection PyUnresolvedReferences
from data_mathobjects import basic_couplets


# Ground set structures for the basic_couplets.
_basic_couplet_struct = CartesianProduct(GenesisSetA(), GenesisSetA())
_complex_couplet_struct = CartesianProduct(_basic_couplet_struct, PowerSet(GenesisSetA()))
_basic_couplets_structs = {
    '2->3': _basic_couplet_struct,
    "'4'->'5'": _basic_couplet_struct,
    "6->'7'": _basic_couplet_struct,
    'Coupl->Set': _complex_couplet_struct
}


class CoupletTest(unittest.TestCase):
    """Test the Couplet class."""

    print_examples = False

    def test_Couplet(self):
        """Create various forms of Couplets."""