algebraixlib.mathobjects.multiset module¶
Provide the class Multiset; it represents a multiset.
-
class
algebraixlib.mathobjects.multiset.Multiset(*args, direct_load=False)[source]¶ Bases:
algebraixlib.mathobjects.mathobject.MathObjectA multiset consisting of zero or more different
MathObjectinstances.Parameters: - args – Zero or more unnamed arguments that are placed into the created
Multiset. If you want to pass in an iterable, you need to prefix it with an asterisk*. If no argument is given or the given iterable is empty, an empty multiset is created. (A Python string of typestris an iterable, but it is considered a single, non-iterable argument.) Arguments of typeCounterare loaded directly, and arguments of typedictmust map values or instances ofMathObjectto integers; the integers are interpreted as multiplicity values for the given keys. (In order to create aMultisetthat contains aCounterordict, put theCounterordictin anAtomor an array first.) - direct_load – (Optional) Set to
Trueif you know that all arguments (or all elements of the iterable) are instances ofMathObject.
-
data¶ Read-only; return the elements of this instance as a
CounterofMathObjectinstances.Note
Even though the returned data is a
dictand can be modified, this should be avoided if at all possible, and if needed, it should be done with care. It may only be done as long as the instance has not been read by code other than the modifying code, and as long as the hash has not yet been calculated. Modifying the data must follow the ‘as-if’ rule: the modification must be done in a way as if the instance were immutable (for all relevant purposes).
-
has_element(elem: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]¶ Return whether
elemis an element of this multiset.elemmust be aMathObject.For a more relaxed version (that auto-converts non-
MathObjectarguments into instances ofAtom) see__contains__and the constructelem in Multiset.
-
get_multiplicity(elem: algebraixlib.mathobjects.mathobject.MathObject) → int[source]¶ Return
intifelemis an element of thisMultisetwhere the value is the number of multiples forelem.elemmust be aMathObject.
-
get_ground_set() → algebraixlib.structure.Structure[source]¶ Return the ground set of the lowest-level algebra of this
Multiset.
-
get_left_set()[source]¶ Get the left set for this
Multiset. ReturnUndef()if not applicable.Todo
Once multipowersets are fully implemented, see
get_left_set().
-
get_right_set()[source]¶ Get the right set for this
Multiset. ReturnUndef()if not applicable.Todo
Once multipowersets are fully implemented, see
get_right_set().
-
__contains__(item)[source]¶ Return
Trueifitemis a member of this multiset. Ifitemis not aMathObject, it is converted into anAtom.This allows Boolean expressions of the form
element in Multiset.
-
__le__(other, NotImplemented=NotImplemented)¶ Return a <= b. Computed by @total_ordering from (a < b) or (a == b).
-
__getitem__(left)[source]¶ With the syntax
mo[left], return a set of rights associated withleft.Parameters: left – The left component of the couplet(s) of which the right component(s) are returned. Returns: If selfis a multi-relation, return a multiset that contains the right(s) of the couplet(s) that have a left component that matchesleft. (The returned multiset may be empty if no couplet with the given left exists.) ReturnUndef()ifselfis not a multi-relation.
- args – Zero or more unnamed arguments that are placed into the created