{ } Raw JSON

bundles / numpy 2.4.4 / numpy / ma / core / masked_values

function

numpy.ma.core:masked_values

source: /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_like

Array to mask.

value : float

Masking value.

rtol, atol : float, optional

Tolerance parameters passed on to isclose

copy : bool, optional

Whether to return a copy of x.

shrink : bool, optional

Whether to collapse a mask full of False to nomask.

Returns

result : MaskedArray

The result of masking x where approximately equal to value.

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