algebraixlib.mathobjects.atom module¶
Provide the class Atom that represents atoms and the function
auto_convert() that passes through instances of MathObjects and converts other types into
Atom instances.
-
algebraixlib.mathobjects.atom.auto_convert(arg)[source]¶ Return always a
MathObject. Ifargis not aMathObject, make it anAtom.This function is used in several constructors as convenience wrapper to allow the creation of
MathObjectinstances from non-MathObjectvalues.
-
class
algebraixlib.mathobjects.atom.Atom(value, direct_load=False)[source]¶ Bases:
algebraixlib.mathobjects.mathobject.MathObjectRepresent a value (of a non-
MathObject, hashable type) like numbers or strings.All instances of
Atomare members of set A (\(A\)), or conversely, set A is the set of all instances ofAtom.Note
Instances of
Atomare immutable and hashable. Therefore they only accept immutable and hashable values.Parameters: - value – The value of this instance. May not be an instance of
MathObjectother thanAtom. (If it is of typeAtom, the instance is re-used; see__new__.)valuemust be immutable and hashable. - direct_load – Set to
Trueif you can be sure thatvalueis not an instance ofMathObject. Default isFalse.
Raise: TypeErrorifvalueis not hashable.-
static
__new__(value, direct_load=False)[source]¶ If
valueis an instance ofAtom, reuse it.This mechanism is used to reduce the number of created
Atominstances. We then need to check in__init__whether we have an already initialized instance or still have to initialize it.__init__is always called after__new__.Returns: valueif it is an instance ofAtom(in this case we simply reuse it). If not, follow the normal path for creating an instance.
-
type¶ Read-only; return the type of this instance.
-
get_ground_set() → algebraixlib.structure.Structure[source]¶ Return the ground set of the lowest-level algebra of
self. Is always \(A\).
-
__eq__(other)[source]¶ A value-based comparison for equality. Return
Trueif types and values match.Type-matching follows Python rules, so
not Atom(1) == Atom(1.0).
-
__ne__(other)[source]¶ A value-based comparison for inequality. Return
Trueif types or values don’t match.Type-matching follows Python rules, so
Atom(1) != Atom(1.0).
-
__le__(other, NotImplemented=NotImplemented)¶ Return a <= b. Computed by @total_ordering from (a < b) or (a == b).
- value – The value of this instance. May not be an instance of