bundles / numpy latest / numpy / ma / core / masked_values
function
numpy.ma.core:masked_values
source: build-install/usr/lib/python3.14/site-packages/numpy/ma/core.py :2316
Signature
def masked_values ( x , value , rtol = 1e-05 , atol = 1e-08 , copy = True , shrink = True ) Summary
Mask using floating point equality.
Extended Summary
Return a MaskedArray, masked where the data in array x are approximately equal to value, determined using isclose. The default tolerances for masked_values are the same as those for isclose.
For integer types, exact equality is used, in the same way as masked_equal.
The fill_value is set to value and the mask is set to nomask if possible.
Parameters
x: array_likeArray to mask.
value: floatMasking value.
rtol, atol: float, optionalTolerance parameters passed on to isclose
copy: bool, optionalWhether to return a copy of
x.shrink: bool, optionalWhether to collapse a mask full of False to
nomask.
Returns
result: MaskedArrayThe result of masking
xwhere approximately equal tovalue.
Examples
import numpy as np import numpy.ma as ma x = np.array([1, 1.1, 2, 1.1, 3]) ma.masked_values(x, 1.1)Note that `mask` is set to ``nomask`` if possible.
ma.masked_values(x, 2.1)
Unlike `masked_equal`, `masked_values` can perform approximate equalities.
ma.masked_values(x, 2.1, atol=1e-1)
See also
- masked_equal
Mask where equal to a given value (integers).
- masked_where
Mask where a condition is met.
Aliases
-
numpy.ma.masked_values