scipp.pow#
- scipp.pow(base, exponent)#
Element-wise power.
If the base has a unit, the exponent must be scalar in order to get a well-defined unit in the result.
- Parameters:
- Raises:
scipp.DTypeError – If the dtype does not have a power, e.g., if it is a string.
- Returns:
TypeVar(_T) –baseraised to the power ofexp.
Examples
Raise values to a scalar power:
>>> import scipp as sc >>> x = sc.array(dims=['x'], values=[1.0, 2.0, 3.0], unit='m') >>> sc.pow(x, 2) <scipp.Variable> (x: 3) float64 [m^2] [1, 4, 9]
Element-wise power with array exponents (base must be dimensionless):
>>> x = sc.array(dims=['x'], values=[2.0, 4.0, 8.0]) >>> y = sc.array(dims=['x'], values=[1.0, 2.0, 3.0]) >>> sc.pow(x, y) <scipp.Variable> (x: 3) float64 [dimensionless] [2, 16, 512]
Units are raised to the power in the result.