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 singleMathObject
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
ofMathObject
instances.
-
is_left_regular
() → bool[source]¶ Return
True
if thisMultiset
is left-regular. ReturnUndef
if not applicable.
-
cardinality
¶ Read-only; return the number of elements in the
Multiset
.
-
is_empty
¶ Return
True
if thisMultiset
is empty.
-
has_element
(elem: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]¶ Return
True
ifelem
is an element of thisMultiset
.elem
must be aMathObject
.For a more relaxed version (that auto-converts non-
MathObject
arguments into instances ofAtom
) see__contains__
and the constructelem in Multiset
.
-
get_multiplicity
(elem: algebraixlib.mathobjects.mathobject.MathObject) → int[source]¶ Return
int
ifelem
is an element of thisMultiset
where the value is the number of multiples forelem
.elem
must be aMathObject
.
-
get_ground_set
() → algebraixlib.structure.Structure[source]¶ Return the ground Multiset of the lowest-level algebra of this
Multiset
.
-
__contains__
(item)[source]¶ Return
True
ifitem
is a member of this Multiset. Ifitem
is not aMathObject
, it is converted into anAtom
.This allows Boolean expressions of the form
element in Multiset
.
- Construct a