dask.array.ma.masked_invalid

dask.array.ma.masked_invalid

dask.array.ma.masked_invalid(a)[source]

Mask an array where invalid values occur (NaNs or infs).

This docstring was copied from numpy.ma.masked_invalid.

Some inconsistencies with the Dask version may exist.

This function is a shortcut to masked_where, with condition = ~(np.isfinite(a)). Any pre-existing mask is conserved. Only applies to arrays with a dtype where NaNs or infs make sense (i.e. floating point types), but accepts any array_like object.

See also

masked_where

Mask where a condition is met.

Examples

>>> import numpy.ma as ma  
>>> a = np.arange(5, dtype=float)  
>>> a[2] = np.NaN  
>>> a[3] = np.PINF  
>>> a  
array([ 0.,  1., nan, inf,  4.])
>>> ma.masked_invalid(a)  
masked_array(data=[0.0, 1.0, --, --, 4.0],
             mask=[False, False,  True,  True, False],
       fill_value=1e+20)