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

Function getmaskarray

numpy/ma/core.py:1424–1474  ·  view source on GitHub ↗

Return the mask of a masked array, or full boolean array of False. Return the mask of `arr` as an ndarray if `arr` is a `MaskedArray` and the mask is not `nomask`, else return a full boolean array of False of the same shape as `arr`. Parameters ---------- arr : array_l

(arr)

Source from the content-addressed store, hash-verified

1422
1423
1424def getmaskarray(arr):
1425 """
1426 Return the mask of a masked array, or full boolean array of False.
1427
1428 Return the mask of `arr` as an ndarray if `arr` is a `MaskedArray` and
1429 the mask is not `nomask`, else return a full boolean array of False of
1430 the same shape as `arr`.
1431
1432 Parameters
1433 ----------
1434 arr : array_like
1435 Input `MaskedArray` for which the mask is required.
1436
1437 See Also
1438 --------
1439 getmask : Return the mask of a masked array, or nomask.
1440 getdata : Return the data of a masked array as an ndarray.
1441
1442 Examples
1443 --------
1444 >>> import numpy.ma as ma
1445 >>> a = ma.masked_equal([[1,2],[3,4]], 2)
1446 >>> a
1447 masked_array(
1448 data=[[1, --],
1449 [3, 4]],
1450 mask=[[False, True],
1451 [False, False]],
1452 fill_value=2)
1453 >>> ma.getmaskarray(a)
1454 array([[False, True],
1455 [False, False]])
1456
1457 Result when mask == ``nomask``
1458
1459 >>> b = ma.masked_array([[1,2],[3,4]])
1460 >>> b
1461 masked_array(
1462 data=[[1, 2],
1463 [3, 4]],
1464 mask=False,
1465 fill_value=999999)
1466 >>> ma.getmaskarray(b)
1467 array([[False, False],
1468 [False, False]])
1469
1470 """
1471 mask = getmask(arr)
1472 if mask is nomask:
1473 mask = make_mask_none(np.shape(arr), getattr(arr, 'dtype', None))
1474 return mask
1475
1476
1477def is_mask(m):

Callers 15

__setattr__Method · 0.90
fromarraysFunction · 0.90
addfieldFunction · 0.90
test_2d_with_missingMethod · 0.90
test_getmaskarrayMethod · 0.90
__call__Method · 0.85
outerMethod · 0.85
flatten_structured_arrayFunction · 0.85
__setitem__Method · 0.85
__new__Method · 0.85
__array_finalize__Method · 0.85

Calls 3

getmaskFunction · 0.85
make_mask_noneFunction · 0.85
shapeMethod · 0.45

Tested by 3

test_2d_with_missingMethod · 0.72
test_getmaskarrayMethod · 0.72