colour.algebra.spow#

colour.algebra.spow(a: FloatingOrArrayLike, p: FloatingOrArrayLike) FloatingOrNDArray[source]#

Raise given array \(a\) to the power \(p\) as follows: \(sign(a) * |a|^p\).

This definition avoids NaNs generation when array \(a\) is negative and the power \(p\) is fractional. This behaviour can be enabled or disabled with the colour.algebra.set_spow_enable() definition or with the spow_enable() context manager.

Parameters
  • a (FloatingOrArrayLike) – Array \(a\).

  • p (FloatingOrArrayLike) – Power \(p\).

Returns

Array \(a\) safely raised to the power \(p\).

Return type

np.floating or numpy.ndarray

Examples

>>> np.power(-2, 0.15)
nan
>>> spow(-2, 0.15)  
-1.1095694...
>>> spow(0, 0)
0.0