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

Function masked_object

numpy/ma/core.py:2192–2257  ·  view source on GitHub ↗

Mask the array `x` where the data are exactly equal to value. This function is similar to `masked_values`, but only suitable for object arrays: for floating point, use `masked_values` instead. Parameters ---------- x : array_like Array to mask value : object

(x, value, copy=True, shrink=True)

Source from the content-addressed store, hash-verified

2190
2191
2192def masked_object(x, value, copy=True, shrink=True):
2193 """
2194 Mask the array `x` where the data are exactly equal to value.
2195
2196 This function is similar to `masked_values`, but only suitable
2197 for object arrays: for floating point, use `masked_values` instead.
2198
2199 Parameters
2200 ----------
2201 x : array_like
2202 Array to mask
2203 value : object
2204 Comparison value
2205 copy : {True, False}, optional
2206 Whether to return a copy of `x`.
2207 shrink : {True, False}, optional
2208 Whether to collapse a mask full of False to nomask
2209
2210 Returns
2211 -------
2212 result : MaskedArray
2213 The result of masking `x` where equal to `value`.
2214
2215 See Also
2216 --------
2217 masked_where : Mask where a condition is met.
2218 masked_equal : Mask where equal to a given value (integers).
2219 masked_values : Mask using floating point equality.
2220
2221 Examples
2222 --------
2223 >>> import numpy.ma as ma
2224 >>> food = np.array(['green_eggs', 'ham'], dtype=object)
2225 >>> # don't eat spoiled food
2226 >>> eat = ma.masked_object(food, 'green_eggs')
2227 >>> eat
2228 masked_array(data=[--, 'ham'],
2229 mask=[ True, False],
2230 fill_value='green_eggs',
2231 dtype=object)
2232 >>> # plain ol` ham is boring
2233 >>> fresh_food = np.array(['cheese', 'ham', 'pineapple'], dtype=object)
2234 >>> eat = ma.masked_object(fresh_food, 'green_eggs')
2235 >>> eat
2236 masked_array(data=['cheese', 'ham', 'pineapple'],
2237 mask=False,
2238 fill_value='green_eggs',
2239 dtype=object)
2240
2241 Note that `mask` is set to ``nomask`` if possible.
2242
2243 >>> eat
2244 masked_array(data=['cheese', 'ham', 'pineapple'],
2245 mask=False,
2246 fill_value='green_eggs',
2247 dtype=object)
2248
2249 """

Callers

nothing calls this directly

Calls 3

isMaskedArrayFunction · 0.85
mask_orFunction · 0.85
make_maskFunction · 0.85

Tested by

no test coverage detected