scipp.reciprocal#
- scipp.reciprocal(x, *, out=None)#
Element-wise reciprocal.
- Parameters:
- Raises:
scipp.DTypeError – If the dtype has no reciprocal, e.g., if it is a string.
- Returns:
TypeVar(_T) – The reciprocal values of the input.
Examples
Compute reciprocal (1/x):
>>> import scipp as sc >>> x = sc.array(dims=['x'], values=[1.0, 2.0, 4.0], unit='m') >>> sc.reciprocal(x) <scipp.Variable> (x: 3) float64 [1/m] [1, 0.5, 0.25]
Units are inverted in the result:
>>> x = sc.array(dims=['x'], values=[2.0, 5.0], unit='s') >>> sc.reciprocal(x) <scipp.Variable> (x: 2) float64 [Hz] [0.5, 0.2]