TensorStructure
symbolica.community.tensor Class
TensorStructure(slots: Sequence[Slot | Representation]) The canonical external signature of an opaque tensor.
A Slot denotes a labeled axis; a Representation denotes an unresolved axis. This immutable signature contains only free axes: no tensor name, scalar arguments, expression, component data, or layout permutation. Axes follow Spenso's canonical representation/index ordering. A(i,j), A(j,i), and their sum have the same structure. The expression retains argument order; tensor and network component views retain their own axis order.
Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(3)
A = TensorName("A")(space, space)
metadata = A.structure
metadata.rankConstructor
#Describe an opaque tensor by its canonical free axes.
Returns
TensorStructure
Canonical signature, independent of the supplied sequence order.
Examples
from symbolica.community.tensor import Representation, TensorStructure
metadata = TensorStructure([Representation.euc(2), Representation.euc(3)])
metadata.shapeParameters
| Name | Type | Default | Description |
|---|---|---|---|
slots | Sequence[ | — | Free axes, sorted into canonical order. Repeated unresolved spaces remain distinct axes. This describes a signature without contracting it. |
Member details
axes
Property · read-only#axes: tuple[Slot | Representation, ...] Free axes in canonical representation/index order.
The signature is independent of argument order, factor order, and summand order. It describes the whole expression as an opaque tensor. Component coordinates belong to the tensor's current view, not to this signature.
Returns
tuple of Slot or Representation
Labeled and unresolved axes, respectively.
Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(3)
A = TensorName("A")(space, space)
A.structure.axes == (space, space)rank
Property · read-only#rank: intNumber of external tensor axes.
Returns
int
Zero for a scalar.
Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(3)
A = TensorName("A")(space, space)
A = A.structure
A.rankshape
Property · read-only#shape: tuple[int | Expression, ...] Dimensions in canonical signature order.
Returns
tuple of int or Expression
Concrete dimensions are integers; symbolic dimensions remain expressions.
Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(3)
A = TensorName("A")(space, space)
A = A.structure
A.shapeis_scalar
Property · read-only#is_scalar: boolWhether the tensor has no external axes.
Returns
bool
True exactly when rank is zero.
Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(3)
A = TensorName("A")(space, space)
A = A.structure
A.is_scalar__eq__
Method#__eq__(other: object) -> boolNo description is available for this member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
other | object | — | — |
slots
Method#slots() -> list[Slot] Return every external axis as an explicitly indexed slot.
Returns
list of Slot
Slots in canonical order; an empty list for a scalar. Representations and dimensions may differ between axes.
Raises
ValueErrorIf any axis is unresolved. No indices are invented or axes omitted. Use
axesto inspect a mixed structure.
Examples
from symbolica.community.tensor import Representation, TensorStructure
space = Representation.euc(3)
metadata = TensorStructure([space("j"), space("i")])
metadata.slots() == TensorStructure([space("i"), space("j")]).slots()representations
Method#representations() -> list[Representation] Return every external axis as an unresolved representation.
Returns
list of Representation
Representations in canonical order; an empty list for a scalar. Different spaces, dimensions, and dualities are allowed.
Raises
ValueErrorIf any axis has an explicit index. Labels are never discarded. Use
axesto inspect a mixed structure.
Examples
from symbolica.community.tensor import Representation, TensorStructure
spaces = [Representation.mink(4), Representation.euc(3)]
TensorStructure(spaces) == TensorStructure(spaces[::-1])__repr__
Method#__repr__() -> strReturn a readable object description for inspection.
Examples
from symbolica.community import tensor as sp
r = sp.Representation.euc(2)
structure = sp.TensorStructure([r("i"), r("j")])
text = repr(structure)to_html
Method#to_html(*, settings: Optional[DisplaySettings] = None) -> str Render a compact HTML view of this tensor metadata.
Returns
str
HTML fragment for display in a notebook or page.
Examples
from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(2)
A = TensorName("M")(space, space)
value = A.structure
html = value.to_html()Parameters
| Name | Type | Default | Description |
|---|---|---|---|
settings | Optional[ | None | Index and tensor presentation choices; defaults to DisplaySettings(). |
_repr_html_
Method#_repr_html_() -> strNo description is available for this member.
View generated signature source: docs/api/python/spynso3.pyi:10404