Slot

Symbolica documentation for getting started, symbolic expressions, numerical evaluation, pattern matching, and APIs in Python and Rust.

Slot

class Slot

One 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)
True

Attributes

Name Description
index The abstract label carried by this slot.
representation The dimensioned space to which this index belongs.

index

Slot.index: Expression

The abstract label carried by this slot.

Returns

  • Expression Symbolic label or integer; not a component coordinate.

Examples

from symbolica.community.tensor import Representation
slot = Representation.euc(3)("i")
label = slot.index

representation

Slot.representation: Representation

The dimensioned space to which this index belongs.

Returns

  • Representation Includes the duality of the slot.

Examples

from symbolica.community.tensor import Representation
slot = Representation.euc(3)("i")
space = slot.representation

Methods

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

Hash 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,
) -> Slot

Create 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

  • Slot The 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.str

Return 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.str

Return 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.str

dual

Slot.dual() -> Slot

Pair this index label with the dual representation.

Returns

  • Slot A 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() -> Expression

Return symbolic syntax for the representation and index.

Returns

  • Expression The 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.str

Render a compact HTML view of this tensor metadata.

Parameters

  • settings (DisplaySettings, optional) Index and tensor presentation choices; defaults to DisplaySettings().

Returns

  • str HTML fragment for display in a notebook or page.

Examples

from symbolica.community.tensor import Representation
value = Representation.euc(3)("i")
html = value.to_html()