Shape
XTensor methods that change rank, size, or axis
order — reshaping, (un)squeezing, transposing/permuting, and broadcasting —
carrying names along with the data.
Bases: ExtendedTensor
A tensor with named dimensions and, optionally, per-dimension coordinate
labels -- an xarray-like DataArray over a
live torch.Tensor.
- Dimensions are named through
names(self-managed in_axis_names, independent of PyTorch's experimental builtin named-tensor feature, so the class works even where that API has been removed). - Coordinates label the positions along a named dimension. They live
in
coords-- a mapping dim name -> labels -- keyed by dimension name, so they follow their dimension through reshaping/reordering with no positional bookkeeping. A labelled dimension must be named. - Axis descriptors may enrich a name with extra fields -- any custom
key you like (
typeis the OME-NGFF convention shown in examples;orientationis the one field with built-in behaviour) -- passed as a dict in place of a bare name ({"name": "x", "type": "space"}).namesstays the ergonomic view (bare names);axesreturns the full descriptors. The extra fields live in_axis_meta, keyed by dimension name, so they follow the dimension like coordinates do.
Select by label with sel, by integer position with isel, or reach a
single label by attribute (x.red).
Attributes
Methods:
broadcast_to
Name-aware torch.broadcast_to: behaves like torch.broadcast_to, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.broadcast_to for the full numerical behaviour.
diagonal
Name-aware torch.diagonal: behaves like torch.diagonal, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.diagonal for the full numerical behaviour.
expand
Name-aware torch.expand: behaves like torch.expand, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.expand for the full numerical behaviour.
flatten
Name-aware torch.flatten: behaves like torch.flatten, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.flatten for the full numerical behaviour.
moveaxis
Name-aware torch.moveaxis: behaves like torch.moveaxis, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.moveaxis for the full numerical behaviour.
movedim
Name-aware torch.movedim: behaves like torch.movedim, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.movedim for the full numerical behaviour.
permute
Name-aware torch.permute: behaves like torch.permute, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.permute for the full numerical behaviour.
reshape
Name-aware torch.reshape: behaves like torch.reshape, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.reshape for the full numerical behaviour.
squeeze
Name-aware torch.squeeze: behaves like torch.squeeze, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.squeeze for the full numerical behaviour.
swapaxes
Name-aware torch.swapaxes: behaves like torch.swapaxes, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.swapaxes for the full numerical behaviour.
swapdims
Name-aware torch.swapdims: behaves like torch.swapdims, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.swapdims for the full numerical behaviour.
transpose
Name-aware torch.transpose: behaves like torch.transpose, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.transpose for the full numerical behaviour.
unflatten
Name-aware torch.unflatten: behaves like torch.unflatten, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.unflatten for the full numerical behaviour.
unsqueeze
Name-aware torch.unsqueeze: behaves like torch.unsqueeze, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.unsqueeze for the full numerical behaviour.