scipp.nansum#

scipp.nansum(x, dim=None)#

Sum of elements in the input ignoring NaN’s.

See scipp.sum() on how rounding errors for float32 inputs are handled.

Parameters:
Returns:

Same type as x – The sum of the input values which are not NaN.

See also

scipp.sum

Compute the sum without special handling of NaN.

Examples

>>> import scipp as sc
>>> import numpy as np
>>> x = sc.array(dims=['x'], values=[1.0, np.nan, 3.0, 4.0])
>>> sc.nansum(x)
<scipp.Variable> ()    float64  [dimensionless]  8