Spenso · latest
On this page

TensorName

symbolica.community.tensor Class

TensorName(name: str, *, rank: Optional[int] = None, is_symmetric: Optional[bool] = None, is_antisymmetric: Optional[bool] = None, is_cyclesymmetric: Optional[bool] = None, is_linear: Optional[bool] = None, is_flat: Optional[bool] = None, is_scalar: Optional[bool] = None, is_real: Optional[bool] = None, is_integer: Optional[bool] = None, is_positive: Optional[bool] = None, tags: Optional[Sequence[str]] = None, aliases: Optional[Sequence[str]] = None, normalization: Optional[symbolica.core.Transformer | Callable[[symbolica.core.Expression], symbolica.core.Expression]] = None, print: Optional[dict[str, str] | Callable[..., str | None]] = None, derivative: Optional[Any] = None, series: Optional[Any] = None, eval: Optional[Any] = None, data: Optional[_ScalarInput | str | dict | list | bytes] = None)

A registered function name for symbolic tensors of arbitrary index spaces.

Call a name with scalar arguments followed by Slots or Representations to create a TensorExpression. The latter leave axes unresolved for later indexing. Use vector for a rank-one name that also supports compact dot notation. Predefined accessors identify standard tensors; use TensorExpression factories to construct their correctly ordered axes and TensorPattern for matching.

Examples

from symbolica.community.tensor import Representation, TensorName, TensorExpression
space = Representation.euc(3)
A = TensorName("A")(space, space)
A("i", "j").rank

Constructor

#

Register a tensor function name.

Returns

TensorName

A callable name for constructing symbolic tensors.

Examples

from symbolica.community.tensor import TensorName, Representation
J = TensorName("Jbar", print={"typst": "overline(J)"})
vector = J(Representation.euc(3))
vector.rank

Parameters

NameTypeDefaultDescription
namestr—

Symbolica function name. Passing only a previously registered name reuses its attributes and printers.

rankOptional[int]None

None permits arbitrary rank. Only rank=1 is supported as a fixed rank; it requires exactly one structural axis in each call.

is_symmetricOptional[bool]None

Symmetry of the function arguments under all permutations, signed permutations, or cyclic rotations. These affect scalar arguments as well as index arguments. Repeated arguments in an antisymmetric call make that call zero.

is_antisymmetricOptional[bool]None

Symmetry of the function arguments under all permutations, signed permutations, or cyclic rotations. These affect scalar arguments as well as index arguments. Repeated arguments in an antisymmetric call make that call zero.

is_cyclesymmetricOptional[bool]None

Symmetry of the function arguments under all permutations, signed permutations, or cyclic rotations. These affect scalar arguments as well as index arguments. Repeated arguments in an antisymmetric call make that call zero.

is_linearOptional[bool]None

Distribute the function over sums in its arguments.

is_flatOptional[bool]None

Flatten nested calls with the same head.

is_scalarOptional[bool]None

Declare calls scalar for Symbolica's algebra. Do not use True for a tensor head with free indices.

is_realOptional[bool]None

Assumptions used by Symbolica for the registered symbol.

is_integerOptional[bool]None

Assumptions used by Symbolica for the registered symbol.

is_positiveOptional[bool]None

Assumptions used by Symbolica for the registered symbol.

tagsOptional[Sequence[str]]None

Additional Symbolica tags; Spenso's required tags are included automatically.

aliasesOptional[Sequence[str]]None

Additional names for the same Symbolica symbol.

normalizationOptional[symbolica.core.Transformer | Callable[[symbolica.core.Expression], symbolica.core.Expression]]None

Normalize a newly constructed call. A callable receives an Expression and returns its normalized Expression; tensor interfaces must remain valid.

printOptional[dict[str, str] | Callable[..., str | None]]None

A mapping with keys "plain", "latex", "typst", or "mathml" changes just the displayed tensor name. Plain, LaTeX and Typst values are bounded display text without math delimiters, for example {"typst": "overline(J)"}. MathML accepts a bounded presentation subset with validated attributes; executable markup, namespaces and unknown entities raise ValueError. Notation is process-local and is not saved with expressions. Equal re-registration succeeds; conflicting notation raises ValueError. Spenso adds arguments and indices. A callable uses Symbolica's print callback convention and replaces the complete display; returning None selects the standard display.

derivativeOptional[Any]None

Symbolica callbacks for differentiation, series expansion, and numerical evaluation. Their arguments and results follow symbolica.S.

seriesOptional[Any]None

Symbolica callbacks for differentiation, series expansion, and numerical evaluation. Their arguments and results follow symbolica.S.

evalOptional[Any]None

Symbolica callbacks for differentiation, series expansion, and numerical evaluation. Their arguments and results follow symbolica.S.

dataOptional[_ScalarInput | str | dict | list | bytes]None

Symbolica user data attached to the symbol, such as a dict, list, or bytes.

Member details

_repr_html_

Method#
_repr_html_() -> Optional[str]

No description is available for this member.

_repr_latex_

Method#
_repr_latex_() -> str

No description is available for this member.

vector

Static method#
vector(name: str, *, is_symmetric: Optional[bool] = None, is_antisymmetric: Optional[bool] = None, is_cyclesymmetric: Optional[bool] = None, is_linear: Optional[bool] = None, is_flat: Optional[bool] = None, is_scalar: Optional[bool] = None, is_real: Optional[bool] = None, is_integer: Optional[bool] = None, is_positive: Optional[bool] = None, tags: Optional[Sequence[str]] = None, aliases: Optional[Sequence[str]] = None, normalization: Optional[symbolica.core.Transformer | Callable[[symbolica.core.Expression], symbolica.core.Expression]] = None, print: Optional[dict[str, str] | Callable[..., str | None]] = None, derivative: Optional[Any] = None, series: Optional[Any] = None, eval: Optional[Any] = None, data: Optional[_ScalarInput | str | dict | list | bytes] = None) -> TensorName

Register a tensor function with exactly one axis.

Returns

TensorName

A callable name for constructing symbolic tensors.

Examples

from symbolica.community.tensor import TensorName, Representation
J = TensorName.vector("Jbar_vector", print={"typst": "overline(J)"})
vector = J(Representation.euc(3))
vector.rank

Parameters

NameTypeDefaultDescription
namestr—

Symbolica function name. Passing only a previously registered name reuses its attributes and printers.

is_symmetricOptional[bool]None

Symmetry of the function arguments under all permutations, signed permutations, or cyclic rotations. These affect scalar arguments as well as index arguments. Repeated arguments in an antisymmetric call make that call zero.

is_antisymmetricOptional[bool]None

Symmetry of the function arguments under all permutations, signed permutations, or cyclic rotations. These affect scalar arguments as well as index arguments. Repeated arguments in an antisymmetric call make that call zero.

is_cyclesymmetricOptional[bool]None

Symmetry of the function arguments under all permutations, signed permutations, or cyclic rotations. These affect scalar arguments as well as index arguments. Repeated arguments in an antisymmetric call make that call zero.

is_linearOptional[bool]None

Distribute the function over sums in its arguments.

is_flatOptional[bool]None

Flatten nested calls with the same head.

is_scalarOptional[bool]None

Declare calls scalar for Symbolica's algebra. Do not use True for a tensor head with free indices.

is_realOptional[bool]None

Assumptions used by Symbolica for the registered symbol.

is_integerOptional[bool]None

Assumptions used by Symbolica for the registered symbol.

is_positiveOptional[bool]None

Assumptions used by Symbolica for the registered symbol.

tagsOptional[Sequence[str]]None

Additional Symbolica tags; Spenso's required tags are included automatically.

aliasesOptional[Sequence[str]]None

Additional names for the same Symbolica symbol.

normalizationOptional[symbolica.core.Transformer | Callable[[symbolica.core.Expression], symbolica.core.Expression]]None

Normalize a newly constructed call. A callable receives an Expression and returns its normalized Expression; tensor interfaces must remain valid.

printOptional[dict[str, str] | Callable[..., str | None]]None

A mapping with keys "plain", "latex", "typst", or "mathml" changes just the displayed tensor name. Plain, LaTeX and Typst values are bounded display text without math delimiters, for example {"typst": "overline(J)"}. MathML accepts a bounded presentation subset with validated attributes; executable markup, namespaces and unknown entities raise ValueError. Notation is process-local and is not saved with expressions. Equal re-registration succeeds; conflicting notation raises ValueError. Spenso adds arguments and indices. A callable uses Symbolica's print callback convention and replaces the complete display; returning None selects the standard display.

derivativeOptional[Any]None

Symbolica callbacks for differentiation, series expansion, and numerical evaluation. Their arguments and results follow symbolica.S.

seriesOptional[Any]None

Symbolica callbacks for differentiation, series expansion, and numerical evaluation. Their arguments and results follow symbolica.S.

evalOptional[Any]None

Symbolica callbacks for differentiation, series expansion, and numerical evaluation. Their arguments and results follow symbolica.S.

dataOptional[_ScalarInput | str | dict | list | bytes]None

Symbolica user data attached to the symbol, such as a dict, list, or bytes.

__repr__

Method#
__repr__() -> str

Return a readable object description for inspection.

Examples

from symbolica.community import tensor as sp
name = sp.TensorName("docs::A")
text = repr(name)

__str__

Method#
__str__() -> str

Return a readable text representation.

Examples

from symbolica.community import tensor as sp
name = sp.TensorName("docs::A")
text = str(name)

to_expression

Method#
to_expression() -> Expression

Return this function name as a Symbolica symbol.

Examples

from symbolica.community import tensor as sp
name = sp.TensorName("docs::A")
symbolic_head = name.to_expression()

Returns

Expression

The bare function head, without arguments or tensor structure.

Examples

from symbolica.community.tensor import TensorName
name = TensorName("tagged_TensorName", tags=["example::example"])
head = name.to_expression()

has_tag

Method#
has_tag(tag: str) -> bool

Check whether the registered function carries a tag.

Returns

bool

Whether the tag is present.

Examples

from symbolica.community.tensor import TensorName
name = TensorName("tagged_TensorName", tags=["example::example"])
name.has_tag("example::example")

Parameters

NameTypeDefaultDescription
tagstr—

Exact tag name. An unqualified name also matches its "python::" form.

get_tags

Method#
get_tags() -> list[str]

List the tags attached to the registered function.

Returns

list of str

Fully qualified tags, including the tags required by Spenso.

Examples

from symbolica.community.tensor import TensorName
name = TensorName("tagged_TensorName", tags=["example::example"])
"example::example" in name.get_tags()

g

Static method#
g() -> TensorName

Return the registered name of the metric pairing.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.g to construct a tensor with distinct unresolved axes, or TensorPattern.g to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.g().to_expression()

flat

Static method#
flat() -> TensorName

Return the registered name of the metric map for raising or lowering an index.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.flat to construct a tensor with distinct unresolved axes, or TensorPattern.flat to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.flat().to_expression()

dirac_gamma

Static method#
dirac_gamma() -> TensorName

Return the registered name of the Dirac gamma matrices for Clifford algebra.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.dirac_gamma to construct a tensor with distinct unresolved axes, or TensorPattern.dirac_gamma to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.dirac_gamma().to_expression()

gamma0

Static method#
gamma0() -> TensorName

Return the registered name of the time-component Dirac matrix gamma^0.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.gamma0 to construct a tensor with distinct unresolved axes, or TensorPattern.gamma0 to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.gamma0().to_expression()

charge_conjugation

Static method#
charge_conjugation() -> TensorName

Return the registered name of the Dirac charge-conjugation matrix.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.charge_conjugation to construct a tensor with distinct unresolved axes, or TensorPattern.charge_conjugation to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.charge_conjugation().to_expression()

levi_civita

Static method#
levi_civita() -> TensorName

Return the registered name of the totally antisymmetric Levi-Civita tensor.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.levi_civita to construct a tensor with distinct unresolved axes, or TensorPattern.levi_civita to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.levi_civita().to_expression()

gamma5

Static method#
gamma5() -> TensorName

Return the registered name of the Dirac chirality matrix gamma^5.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.gamma5 to construct a tensor with distinct unresolved axes, or TensorPattern.gamma5 to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.gamma5().to_expression()

projm

Static method#
projm() -> TensorName

Return the registered name of the left-chiral Dirac projector (I - gamma^5)/2.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.projm to construct a tensor with distinct unresolved axes, or TensorPattern.projm to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.projm().to_expression()

projp

Static method#
projp() -> TensorName

Return the registered name of the right-chiral Dirac projector (I + gamma^5)/2.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.projp to construct a tensor with distinct unresolved axes, or TensorPattern.projp to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.projp().to_expression()

sigma

Static method#
sigma() -> TensorName

Return the registered name of the antisymmetric Dirac sigma tensor.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.sigma to construct a tensor with distinct unresolved axes, or TensorPattern.sigma to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.sigma().to_expression()

color_f

Static method#
color_f() -> TensorName

Return the registered name of the antisymmetric color structure constants f^{abc}.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.color_f to construct a tensor with distinct unresolved axes, or TensorPattern.color_f to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.color_f().to_expression()

color_t

Static method#
color_t() -> TensorName

Return the registered name of the fundamental color generators T^a.

Returns

TensorName

The existing symbolic function head, including its tags and symmetries.

Notes

Use TensorExpression.color_t to construct a tensor with distinct unresolved axes, or TensorPattern.color_t to construct a rewrite pattern. The Python accessor name does not change the underlying Symbolica symbol.

Examples

from symbolica.community.tensor import TensorName
head = TensorName.color_t().to_expression()

__call__

Method#
__call__(*args: Slot | Representation | _ScalarInput) -> TensorExpression

Construct a tensor with scalar arguments and ordered axes.

Returns

TensorExpression

The tensor call, including a scalar tensor when there are no axes. Repeated compatible explicit labels are contracted.

Notes

For predefined metrics, Dirac matrices, and color tensors, prefer the corresponding TensorExpression factory. Fixed-structure names reject direct calls. Symmetries act on the full argument list; an antisymmetric name called twice with exactly the same representation argument is zero.

Examples

from symbolica import S
from symbolica.community.tensor import TensorName, Representation
space = Representation.euc(3)
tensor = TensorName("B")(S("x"), 7, space("i"), space)
tensor.rank

Parameters

NameTypeDefaultDescription
argsSlot | Representation | _ScalarInput——