algebraixlib.mathobjects.multiset module

A math object that represents a Multiset.

class algebraixlib.mathobjects.multiset.Multiset(*args, direct_load=False)[source]

Bases: algebraixlib.mathobjects.mathobject.MathObject

A multiset consisting of zero or more different MathObject instances.

Construct a Multiset from a single MathObject or value or an iterable collection of
such.
Parameters:
  • args – Zero or more unnamed arguments that are placed into the created Multiset.
  • direct_load – Flag they allows bypassing the normal auto-converting of elements. The elements must all be instances of MathObject.

The prefered argument type will be a dictionary whose keys are mapped to positive integers. The keys will be auto-converted based on the direct_load parameter.

Note

A string is an iterable, so an explicit conversion to an Atom (or wrapping it into brackets or braces) is required for multi-character strings.

data

Read-only; return the elements of this instance as a Counter of MathObject instances.

is_left_regular() → bool[source]

Return True if this Multiset is left-regular. Return Undef if not applicable.

cardinality

Read-only; return the number of elements in the Multiset.

is_empty

Return True if this Multiset is empty.

has_element(elem: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]

Return True if elem is an element of this Multiset. elem must be a MathObject.

For a more relaxed version (that auto-converts non-MathObject arguments into instances of Atom) see __contains__ and the construct elem in Multiset.

get_multiplicity(elem: algebraixlib.mathobjects.mathobject.MathObject) → int[source]

Return int if elem is an element of this Multiset where the value is the number of multiples for elem. elem must be a MathObject.

get_ground_set() → algebraixlib.structure.Structure[source]

Return the ground Multiset of the lowest-level algebra of this Multiset.

get_repr() → str[source]

Return the instance’s code representation.

get_str() → str[source]

Return the instance’s string representation.

__eq__(other)[source]

Implement value-based equality. Return True if type and data match.

__ne__(other)[source]

Implement value-based inequality. Return True if type or data don’t match.

__contains__(item)[source]

Return True if item is a member of this Multiset. If item is not a MathObject, it is converted into an Atom.

This allows Boolean expressions of the form element in Multiset.

__hash__()[source]

Return a hash based on the value that is calculated on demand and cached.

__repr__()[source]

Return the instance’s code representation.

__str__()[source]

Return the instance’s string representation.

cache_is_multiclan(value: bool)[source]