ma.masked_values(x, value, rtol=1e-05, atol=1e-08, copy=True, shrink=True)
Mask using floating point equality.
Return a MaskedArray, masked where the data in array x are approximately equal to value, determined using
. The default tolerances for
are the same as those for
.
For integer types, exact equality is used, in the same way as
.
The fill_value is set to value and the mask is set to nomask if possible.
Parameters:xarray_likeArray to mask.
valuefloatMasking value.
rtol, atolfloat, optionalTolerance parameters passed on to
copybool, optionalWhether to return a copy of x.
shrinkbool, optionalWhether to collapse a mask full of False to nomask.
Returns:resultMaskedArrayThe result of masking x where approximately equal to value.
Examples
>>> importnumpyasnp>>> importnumpy.maasma>>> x=np.array([1,1.1,2,1.1,3])>>> ma.masked_values(x,1.1)masked_array(data=[1.0, --, 2.0, --, 3.0], mask=[False, True, False, True, False], fill_value=1.1)Note that mask is set to nomask if possible.
>>> ma.masked_values(x,2.1)masked_array(data=[1. , 1.1, 2. , 1.1, 3. ], mask=False, fill_value=2.1)Unlike
,
can perform approximate equalities.
>>> ma.masked_values(x,2.1,atol=1e-1)masked_array(data=[1.0, 1.1, --, 1.1, 3.0], mask=[False, False, True, False, False], fill_value=2.1)