Inspecting YASTN tensors#

Get information about tensor’s structure and properties#

property Tensor.s: Sequence[int]#

Signature of tensor’s effective legs.

Legs (spaces) fused together by yastn.Tensor.fuse() are treated as a single leg. The signature of each fused leg is given by the first native leg in the fused space.

property Tensor.s_n: Sequence[int]#

Signature of tensor’s native legs.

This includes legs (spaces) which have been fused together by yastn.fuse_legs() using mode='meta'.

property Tensor.n: Sequence[int]#

Total charge of the tensor.

In case of direct product of abelian symmetries, total charge for each symmetry, accummulated in a tuple.

property Tensor.ndim: int#

Effective rank of the tensor.

Legs (spaces) fused together by yastn.fuse_legs() are treated as single leg.

property Tensor.ndim_n: int#

Native rank of the tensor.

This includes legs (spaces) which have been fused together by yastn.fuse_legs() using mode='meta'.

property Tensor.isdiag: bool#

Return True if the tensor is diagonal.

property Tensor.requires_grad: bool#

Return True if tensor data have autograd enabled.

property Tensor.size: int#

Total number of elements in all non-empty blocks of the tensor.

Tensor.print_properties(file=None) Never#
Print basic properties of the tensor:
  • symmetry,

  • signature,

  • total charge,

  • whether it is a diagonal tensor,

  • meta/logical rank - treating meta-fused legs as a single logical leg,

  • native rank,

  • total dimension of all existing charge sectors for each leg, treating meta-fused legs as a single leg,

  • total dimension of all existing charge sectors for native leg,

  • number of non-empty blocks

  • total number of elements across all non-empty blocks,

  • fusion tree for each leg,

  • fusion history with 'o' indicating original legs, 'm' meta-fusion, 'p' hard-fusion (product), 's' blocking (sum).

Tensor.print_blocks_shape() str#

Print shapes of blocks as a sequence of block’s charge followed by its shape.

Tensor.is_complex() bool#

Return True if tensor data are complex.

Tensor.get_rank(native=False) int#

Return tensor rank equivalent to yastn.Tensor.ndim.

If native, the native rank of the tensor is returned, see yastn.Tensor.ndim_n.

Tensor.get_tensor_charge() Sequence[int]#

Return yastn.Tensor.n.

Tensor.get_signature(native=False) Sequence[int]#

Return tensor signature, equivalent to yastn.Tensor.s.

If native, returns the signature of tensors’s native legs, see yastn.Tensor.s_n.

Tensor.get_legs(axes=None, native=False) yastn.Leg | Sequence[yastn.Leg]#

Return a leg or a set of legs of the tensor a.

Parameters:
  • axes (int | Sequence[int] | None) – indices of legs to retrieve. If None returns list with all legs.

  • native (bool) – if True considers native legs; otherwise returns fused legs. Default is native=False.

Tensor.get_blocks_charge() Sequence[Sequence[int]]#

Return charges of all native blocks.

In case of product of abelian symmetries, for each block the individual symmetry charges are flattened into a single tuple.

Tensor.get_blocks_shape() Sequence[Sequence[int]]#

Shapes of all native blocks.

Tensor.get_shape(axes=None, native=False) int | Sequence[int]#

Return effective bond dimensions as sum of dimensions along sectors for each leg.

Parameters:

axes (int | Sequence[int]) – indices of legs; If axes=None returns shape for all legs. Default is axes=None.

Tensor.get_dtype() numpy.dtype | torch.dtype#

dtype of tensor data used by the backend.