algebraixlib.mathobjects.atom module

An atomic math object that represents a value.

algebraixlib.mathobjects.atom.auto_convert(arg)[source]

Return always a MathObject. If arg is not a MathObject, make it an Atom.

This function is used in several constructors as convenience wrapper to allow the creation of MathObject instances from non-MathObject values.

class algebraixlib.mathobjects.atom.Atom(value, direct_load=False)[source]

Bases: algebraixlib.mathobjects.mathobject.MathObject

An atomic math object. It represents a value (of a non-MathObject, hashable type).

Note

Instances of Atom are considered immutable. Therefore they only accept immutable values. Since an Atom also needs to be hashable, the value itself also needs to be hashable.

Construct an instance with the given value.

Parameters:value – The value of the Atom. May not be an instance of MathObject other than Atom. (If it is of type Atom, this Atom is used.) The value must be immutable and hashable.
static __new__(value, direct_load=False)[source]

If value is an Atom, return that Atom, else return a new Atom initialized with value.

Note

This is used to reduce the number of created Atom instances, but doesn’t make the check in __init__ unnecessary. __init__ is always called after __new__.

value

Read-only; return the value of this instance.

get_ground_set()[source]

Return the ground set of the lowest-level algebra of this MathObject. Is always \(A\).

get_repr()[source]

Return the instance’s code representation.

get_str()[source]

Return the instance’s string representation (the string representation of the value).

__eq__(other)[source]

A value-based comparison for equality. Return True if types and values match. NOTE: Atom(1) != Atom(1.0)

__ne__(other)[source]

A value-based comparison for inequality. Return True if types or values don’t match. NOTE: Atom(1) != Atom(1.0)

__hash__()[source]

Return a hash based on the value calculated during construction.

__repr__()[source]

Return the instance’s code representation.

__str__()[source]

Return the instance’s string representation.