Skip to content

Reductions

XTensor methods that collapse (or scan) one or more named dimensions — sums, means, extrema, sorts, and their nan-aware / cumulative variants.

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 (type is the OME-NGFF convention shown in examples; orientation is the one field with built-in behaviour) -- passed as a dict in place of a bare name ({"name": "x", "type": "space"}). names stays the ergonomic view (bare names); axes returns 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).

Methods:

all

all(*args, **kwargs) -> tx.Any

Name-aware torch.all: behaves like torch.all, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.all for the full numerical behaviour.

amax

amax(*args, **kwargs) -> tx.Any

Name-aware torch.amax: behaves like torch.amax, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.amax for the full numerical behaviour.

amin

amin(*args, **kwargs) -> tx.Any

Name-aware torch.amin: behaves like torch.amin, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.amin for the full numerical behaviour.

any

any(*args, **kwargs) -> tx.Any

Name-aware torch.any: behaves like torch.any, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.any for the full numerical behaviour.

argmax

argmax(*args, **kwargs) -> tx.Any

Name-aware torch.argmax: behaves like torch.argmax, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.argmax for the full numerical behaviour.

argmin

argmin(*args, **kwargs) -> tx.Any

Name-aware torch.argmin: behaves like torch.argmin, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.argmin for the full numerical behaviour.

count_nonzero

count_nonzero(*args, **kwargs) -> tx.Any

Name-aware torch.count_nonzero: behaves like torch.count_nonzero, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.count_nonzero for the full numerical behaviour.

cummax

cummax(*args, **kwargs) -> tx.Any

Name-aware torch.cummax: behaves like torch.cummax, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.cummax for the full numerical behaviour.

cummin

cummin(*args, **kwargs) -> tx.Any

Name-aware torch.cummin: behaves like torch.cummin, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.cummin for the full numerical behaviour.

cumprod

cumprod(*args, **kwargs) -> XTensor

Name-aware torch.cumprod: behaves like torch.cumprod, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.cumprod for the full numerical behaviour.

cumsum

cumsum(*args, **kwargs) -> XTensor

Name-aware torch.cumsum: behaves like torch.cumsum, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.cumsum for the full numerical behaviour.

kthvalue

kthvalue(*args, **kwargs) -> tx.Any

Name-aware torch.kthvalue: behaves like torch.kthvalue, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.kthvalue for the full numerical behaviour.

log_softmax

log_softmax(*args, **kwargs) -> XTensor

Name-aware torch.log_softmax: behaves like torch.log_softmax, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.log_softmax for the full numerical behaviour.

logcumsumexp

logcumsumexp(*args, **kwargs) -> XTensor

Name-aware torch.logcumsumexp: behaves like torch.logcumsumexp, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.logcumsumexp for the full numerical behaviour.

logsumexp

logsumexp(*args, **kwargs) -> tx.Any

Name-aware torch.logsumexp: behaves like torch.logsumexp, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.logsumexp for the full numerical behaviour.

max

max(*args, **kwargs) -> tx.Any

Name-aware torch.max: behaves like torch.max, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.max for the full numerical behaviour.

mean

mean(*args, **kwargs) -> tx.Any

Name-aware torch.mean: behaves like torch.mean, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.mean for the full numerical behaviour.

median

median(*args, **kwargs) -> tx.Any

Name-aware torch.median: behaves like torch.median, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.median for the full numerical behaviour.

min

min(*args, **kwargs) -> tx.Any

Name-aware torch.min: behaves like torch.min, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.min for the full numerical behaviour.

mode

mode(*args, **kwargs) -> tx.Any

Name-aware torch.mode: behaves like torch.mode, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.mode for the full numerical behaviour.

nanmean

nanmean(*args, **kwargs) -> tx.Any

Name-aware torch.nanmean: behaves like torch.nanmean, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.nanmean for the full numerical behaviour.

nansum

nansum(*args, **kwargs) -> tx.Any

Name-aware torch.nansum: behaves like torch.nansum, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.nansum for the full numerical behaviour.

norm

norm(*args, **kwargs)

Name-aware torch.norm: behaves like torch.norm, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.norm for the full numerical behaviour.

prod

prod(*args, **kwargs) -> tx.Any

Name-aware torch.prod: behaves like torch.prod, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.prod for the full numerical behaviour.

softmax

softmax(*args, **kwargs) -> XTensor

Name-aware torch.softmax: behaves like torch.softmax, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.softmax for the full numerical behaviour.

sort

sort(*args, **kwargs) -> tx.Any

Name-aware torch.sort: behaves like torch.sort, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.sort for the full numerical behaviour.

std

std(*args, **kwargs) -> tx.Any

Name-aware torch.std: behaves like torch.std, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.std for the full numerical behaviour.

sum

sum(*args, **kwargs) -> tx.Any

Name-aware torch.sum: behaves like torch.sum, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.sum for the full numerical behaviour.

topk

topk(*args, **kwargs) -> tx.Any

Name-aware torch.topk: behaves like torch.topk, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.topk for the full numerical behaviour.

var

var(*args, **kwargs) -> tx.Any

Name-aware torch.var: behaves like torch.var, but this tensor's names (and coordinates, where applicable) propagate onto the result. See torch.var for the full numerical behaviour.