nancumprod#
- class saiunit.math.nancumprod(x, axis=None, dtype=None, **kwargs)#
Return the cumulative product of elements along a given axis treating NaNs as one.
Behaves like
cumprod()but treats NaN values as one, so they do not affect the cumulative product.- Parameters:
x (
Union[saiunit.Quantity,Array,ndarray,number,bool]) – Input array.axis (
Optional[int]) – Axis along which the cumulative product is computed. By default the input is flattened.dtype (
Union[str,type[Any],dtype,SupportsDType,None]) – Type of the returned array, as well as of the accumulator in which the elements are multiplied.
- Returns:
cumprod – A new array holding the cumulative product with NaNs treated as one. If x carries a unit, the result is a Quantity.
- Return type:
Union[saiunit.Quantity,Array,ndarray,number,bool]
Examples
>>> import saiunit as u >>> import jax.numpy as jnp >>> q = u.math.array([2.0, jnp.nan, 3.0]) * u.meter >>> u.math.nancumprod(q)