MCPcopy Create free account
hub / github.com/numpy/numpy / masked_equal

Function masked_equal

numpy/ma/core.py:2080–2109  ·  view source on GitHub ↗

Mask an array where equal to a given value. Return a MaskedArray, masked where the data in array `x` are equal to `value`. The fill_value of the returned MaskedArray is set to `value`. For floating point arrays, consider using ``masked_values(x, value)``. See Also ---

(x, value, copy=True)

Source from the content-addressed store, hash-verified

2078
2079
2080def masked_equal(x, value, copy=True):
2081 """
2082 Mask an array where equal to a given value.
2083
2084 Return a MaskedArray, masked where the data in array `x` are
2085 equal to `value`. The fill_value of the returned MaskedArray
2086 is set to `value`.
2087
2088 For floating point arrays, consider using ``masked_values(x, value)``.
2089
2090 See Also
2091 --------
2092 masked_where : Mask where a condition is met.
2093 masked_values : Mask using floating point equality.
2094
2095 Examples
2096 --------
2097 >>> import numpy.ma as ma
2098 >>> a = np.arange(4)
2099 >>> a
2100 array([0, 1, 2, 3])
2101 >>> ma.masked_equal(a, 2)
2102 masked_array(data=[0, 1, --, 3],
2103 mask=[False, False, True, False],
2104 fill_value=2)
2105
2106 """
2107 output = masked_where(equal(x, value), x, copy=copy)
2108 output.fill_value = value
2109 return output
2110
2111
2112def masked_inside(x, v1, v2, copy=True):

Calls 2

masked_whereFunction · 0.85
equalFunction · 0.50