Skip to content

Pointwise operations

XTensor's elementwise arithmetic, comparison, logical, and trigonometric operations — each behaves exactly like the matching torch.* op, with this tensor's names (and coordinates, where applicable) propagated onto the result.

Not one of the issue's originally proposed sections

Issue #155's candidate list didn't call out _pointwise.py on its own; its ~40 methods were folded into "Core" by omission. They're numerous and self-contained enough to warrant their own page rather than padding out another section.

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:

acos

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

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

acosh

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

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

add

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

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

asin

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

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

asinh

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

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

atan

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

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

atan2

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

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

atanh

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

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

cos

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

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

cosh

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

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

div

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

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

eq

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

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

erf

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

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

erfc

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

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

exp

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

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

expm1

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

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

floor_divide

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

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

ge

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

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

gt

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

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

hypot

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

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

le

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

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

log

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

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

log10

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

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

log1p

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

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

log2

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

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

logical_and

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

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

logical_or

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

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

logical_xor

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

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

lt

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

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

maximum

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

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

minimum

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

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

mul

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

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

ne

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

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

pow

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

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

remainder

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

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

sigmoid

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

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

sin

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

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

sinh

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

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

sub

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

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

tan

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

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

tanh

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

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