Slot
Symbolica documentation for getting started, symbolic expressions, numerical evaluation, pattern matching, and APIs in Python and Rust.
Slot
class SlotOne abstract tensor index together with its representation.
An index label identifies a possible contraction; it is not a component coordinate. Prefer space("i") to construct a slot for an existing space.
Examples
from symbolica.community.tensor import Representation
slot = Representation.euc(3)("i")
slot.representation == Representation.euc(3)
TrueAttributes
| Name | Description |
|---|---|
index |
The abstract label carried by this slot. |
representation |
The dimensioned space to which this index belongs. |
index
Slot.index: ExpressionThe abstract label carried by this slot.
Returns
ExpressionSymbolic label or integer; not a component coordinate.
Examples
from symbolica.community.tensor import Representation
slot = Representation.euc(3)("i")
label = slot.indexrepresentation
Slot.representation: RepresentationThe dimensioned space to which this index belongs.
Returns
RepresentationIncludes the duality of the slot.
Examples
from symbolica.community.tensor import Representation
slot = Representation.euc(3)("i")
space = slot.representationMethods
| Name | Description |
|---|---|
__eq__ |
|
__hash__ |
Hash the immutable representation and index label for dictionaries and sets. |
__new__ |
Create a labeled index in a registered representation. |
__repr__ |
Return a readable object description for inspection. |
__str__ |
Return a readable text representation. |
_repr_html_ |
|
_repr_latex_ |
|
dual |
Pair this index label with the dual representation. |
to_expression |
Return symbolic syntax for the representation and index. |
to_html |
Render a compact HTML view of this tensor metadata. |
__eq__
Slot.__eq__(other: builtins.object) -> builtins.bool__hash__
Slot.__hash__() -> builtins.intHash the immutable representation and index label for dictionaries and sets.
Examples
from symbolica.community import tensor as sp
r = sp.Representation.euc(2)
labels = {r("i"): "free index"}
assert labels[r("i")] == "free index"__new__
Slot.__new__(
name: builtins.str,
dimension: builtins.int,
aind: builtins.int | Expression | str,
dual: builtins.bool = False,
) -> SlotCreate a labeled index in a registered representation.
Parameters
name(str) Registered representation name.dimension(int) Dimension of the index space.aind(int, str, or Expression) Abstract index label accepted by the shared tensor-structure parser, including numeric, symbolic, tagged named, and scoped indices.dual(bool, default False) Whether to use the dual of the named representation.
Returns
SlotThe representation and index label together.
Notes
Use Representation.euc(3)("i") when working with representation objects.
Examples
from symbolica.community.tensor import Representation, Slot
space = Representation.euc(3)
slot = Slot(space.name.name, 3, "i")
slot == space("i")
True__repr__
Slot.__repr__() -> builtins.strReturn a readable object description for inspection.
Examples
from symbolica.community import tensor as sp
slot = sp.Representation.mink(4)("mu")
text = repr(slot)__str__
Slot.__str__() -> builtins.strReturn a readable text representation.
Examples
from symbolica.community import tensor as sp
slot = sp.Representation.mink(4)("mu")
text = str(slot)_repr_html_
Slot._repr_html_() -> builtins.str_repr_latex_
Slot._repr_latex_() -> builtins.strdual
Slot.dual() -> SlotPair this index label with the dual representation.
Returns
SlotA new slot with the same label.
Examples
from symbolica.community.tensor import Representation
slot = Representation.euc(3)("i")
paired = slot.dual()to_expression
Slot.to_expression() -> ExpressionReturn symbolic syntax for the representation and index.
Returns
ExpressionThe encoded slot, for use in raw Symbolica expressions.
Examples
from symbolica.community.tensor import Representation
slot = Representation.euc(3)("i")
encoded = slot.to_expression()to_html
Slot.to_html(*, settings: typing.Optional[DisplaySettings] = None) -> builtins.strRender a compact HTML view of this tensor metadata.
Parameters
settings(DisplaySettings, optional) Index and tensor presentation choices; defaults to DisplaySettings().
Returns
strHTML fragment for display in a notebook or page.
Examples
from symbolica.community.tensor import Representation
value = Representation.euc(3)("i")
html = value.to_html()