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:
x (
scipp.typing.VariableLike) – Input data.dim (
Union[str,Iterable[str],None], default:None) – Dimension(s) along which to calculate the sum. If not given, the sum over all dimensions is calculated.
- Returns:
Same type as x– The sum of the input values which are not NaN.
See also
scipp.sumCompute 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