Argument Functions and Coordinate Functions
Argument functions, when fed with a single xtensors.TensorLike object, return
an XTensor instance with integer data representing the indices
of the original tensor. An example is xtensors.argsmax(), which returns
the indices where the maximum values occur:
Similarly, coordinate functions return the coordinates associated with the axes of the original tensor.
- class xtensors.ArgsFunction(*args, **kwargs)
Bases:
ProtocolArgument function protocol
- __call__(x: TensorLike, /, dim: List[str | int | Tuple[str, int] | HasDimName]) XTensor
- Parameters:
x – target tensor
dim – target dimension(s)
- Returns:
an
XTensorof rankx.rank - len(dim) + 1
- class xtensors.CoordsFunction(*args, **kwargs)
Bases:
ProtocolCoordinate function protocol
- __call__(x: Array | Sequence | float, /, dim: List[str | int | Tuple[str, int] | HasDimName], *, use_index_if_no_coord: bool = False) XTensor
- Parameters:
x – target tensor
dim – target dimension(s)
use_index_if_no_coord – whether to use indices instead of coordinates are not specified
- Returns:
an
XTensorof rankx.rank - len(dim) + 1
- xtensors.argsmax(x: TensorLike, /, dim: DimLike | DimsLike | None) XTensor
Return the indices where maxima occur.
- xtensors.argsmin(x: TensorLike, /, dim: DimLike | DimsLike | None) XTensor
Return the indices where minima occur.
- xtensors.nanargsmax(x: TensorLike, /, dim: DimLike | DimsLike | None) XTensor
Similar to
argsmax(), but withnanignored
- xtensors.nanargsmin(x: TensorLike, /, dim: DimLike | DimsLike | None) XTensor
Similar to
argsmin(), but withnanignored
- xtensors.coordsmax(x: TensorLike, /, dim: DimLike | DimsLike | None, *, use_index_if_no_coord: bool = False) XTensor
Return the coordinates where maxima occur
- xtensors.coordsmin(x: TensorLike, /, dim: DimLike | DimsLike | None, *, use_index_if_no_coord: bool = False) XTensor
Return the coordinates where minima occur
- xtensors.nancoordsmax(x: TensorLike, /, dim: DimLike | DimsLike | None, *, use_index_if_no_coord: bool = False) XTensor
Similar to
coordsmax(), but withnanignored
- xtensors.nancoordsmin(x: TensorLike, /, dim: DimLike | DimsLike | None, *, use_index_if_no_coord: bool = False) XTensor
Similar to
coordsmin(), but withnanignored