scipp.abs#
- scipp.abs(x, *, out=None)#
Element-wise absolute value.
- Parameters:
- Raises:
scipp.DTypeError – If the dtype has no absolute value, e.g., if it is a string.
- Returns:
TypeVar(_T) – The absolute values of the input.
See also
Examples
Basic usage with negative values:
>>> import scipp as sc >>> x = sc.array(dims=['x'], values=[-2.0, -1.0, 0.0, 1.0, 2.0], unit='m') >>> sc.abs(x) <scipp.Variable> (x: 5) float64 [m] [2, 1, ..., 1, 2]
Units are preserved in the output:
>>> x = sc.array(dims=['x'], values=[-5.0, -3.0, 3.0], unit='kg') >>> sc.abs(x) <scipp.Variable> (x: 3) float64 [kg] [5, 3, 3]