MCPcopy Index your code
hub / github.com/numpy/numpy / masked_object

Function masked_object

numpy/ma/core.py:2258–2324  ·  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

2256
2257
2258def masked_object(x, value, copy=True, shrink=True):
2259 """
2260 Mask the array `x` where the data are exactly equal to value.
2261
2262 This function is similar to `masked_values`, but only suitable
2263 for object arrays: for floating point, use `masked_values` instead.
2264
2265 Parameters
2266 ----------
2267 x : array_like
2268 Array to mask
2269 value : object
2270 Comparison value
2271 copy : {True, False}, optional
2272 Whether to return a copy of `x`.
2273 shrink : {True, False}, optional
2274 Whether to collapse a mask full of False to nomask
2275
2276 Returns
2277 -------
2278 result : MaskedArray
2279 The result of masking `x` where equal to `value`.
2280
2281 See Also
2282 --------
2283 masked_where : Mask where a condition is met.
2284 masked_equal : Mask where equal to a given value (integers).
2285 masked_values : Mask using floating point equality.
2286
2287 Examples
2288 --------
2289 >>> import numpy as np
2290 >>> import numpy.ma as ma
2291 >>> food = np.array(['green_eggs', 'ham'], dtype=np.object_)
2292 >>> # don't eat spoiled food
2293 >>> eat = ma.masked_object(food, 'green_eggs')
2294 >>> eat
2295 masked_array(data=[--, 'ham'],
2296 mask=[ True, False],
2297 fill_value='green_eggs',
2298 dtype=object)
2299 >>> # plain ol` ham is boring
2300 >>> fresh_food = np.array(['cheese', 'ham', 'pineapple'], dtype=np.object_)
2301 >>> eat = ma.masked_object(fresh_food, 'green_eggs')
2302 >>> eat
2303 masked_array(data=['cheese', 'ham', 'pineapple'],
2304 mask=False,
2305 fill_value='green_eggs',
2306 dtype=object)
2307
2308 Note that `mask` is set to ``nomask`` if possible.
2309
2310 >>> eat
2311 masked_array(data=['cheese', 'ham', 'pineapple'],
2312 mask=False,
2313 fill_value='green_eggs',
2314 dtype=object)
2315

Callers

nothing calls this directly

Calls 3

isMaskedArrayFunction · 0.85
mask_orFunction · 0.85
make_maskFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…