# algebraixlib.mathobjects.set module¶

Provide the class Set; it represents a set.

algebraixlib.mathobjects.set.make_set(*args)[source]

Factory wrapper to create a Set.

algebraixlib.mathobjects.set.make_set_unchecked(*args)[source]

Factory wrapper to create a Set (unchecked version).

class algebraixlib.mathobjects.set.Set(*args, direct_load=False)[source]

A set containing zero or more different MathObject instances.

Parameters: args – Zero or more unnamed arguments that are placed into the created Set. 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 set is created. (A Python string of type str is an iterable, but it is considered a single, non-iterable argument.) direct_load – (Optional) Set to True if you know that all arguments (or all elements of the iterable) are instances of MathObject.
data

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

cardinality

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

is_empty

Return True if this set is empty, False if not.

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

Return whether elem is an element of this set. 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 Set.

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

Return the ground set of the lowest-level algebra of this Set.

get_left_set()[source]

Get the left set for this Set. Return Undef() if not applicable.

get_right_set()[source]

Get the right set for this Set. Return Undef() if not applicable.

__eq__(other)[source]

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

__ne__(other)[source]

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

__contains__(item)[source]

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

This allows Boolean expressions of the form element in Set.

__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.

__call__()[source]

With the syntax mo(left), return the right associated with left.

Parameters: args – Exactly one argument is expected; it is the left of the couplet of which the right is returned. kwargs – Named arguments are not supported. If self is a function, return the right component of the couplet that has as left the single argument if one exists; return Undef() if no couplet with the given left exists. Also return Undef() if self is not a function.
__le__(other, NotImplemented=NotImplemented)

Return a <= b. Computed by @total_ordering from (a < b) or (a == b).

__getitem__()[source]

With the syntax mo[left], return a set of rights associated with left.

Parameters: left – The left component of the couplet(s) of which the right component(s) are returned. If self is a relation, return a set that contains the right(s) of the couplet(s) that have a left component that matches left. If self is a clan, return a set that contains the right(s) of all couplets in all relations that have a left component that matches left. (The returned set may be empty if no couplet with the given left exists.) Return Undef() if self is neither a relation nor a clan.