MCPcopy
hub / github.com/numpy/numpy / getmask

Function getmask

numpy/ma/core.py:1411–1468  ·  view source on GitHub ↗

Return the mask of a masked array, or nomask. Return the mask of `a` as an ndarray if `a` is a `MaskedArray` and the mask is not `nomask`, else return `nomask`. To guarantee a full array of booleans of the same shape as a, use `getmaskarray`. Parameters ---------- a :

(a)

Source from the content-addressed store, hash-verified

1409
1410
1411def getmask(a):
1412 """
1413 Return the mask of a masked array, or nomask.
1414
1415 Return the mask of `a` as an ndarray if `a` is a `MaskedArray` and the
1416 mask is not `nomask`, else return `nomask`. To guarantee a full array
1417 of booleans of the same shape as a, use `getmaskarray`.
1418
1419 Parameters
1420 ----------
1421 a : array_like
1422 Input `MaskedArray` for which the mask is required.
1423
1424 See Also
1425 --------
1426 getdata : Return the data of a masked array as an ndarray.
1427 getmaskarray : Return the mask of a masked array, or full array of False.
1428
1429 Examples
1430 --------
1431 >>> import numpy as np
1432 >>> import numpy.ma as ma
1433 >>> a = ma.masked_equal([[1,2],[3,4]], 2)
1434 >>> a
1435 masked_array(
1436 data=[[1, --],
1437 [3, 4]],
1438 mask=[[False, True],
1439 [False, False]],
1440 fill_value=2)
1441 >>> ma.getmask(a)
1442 array([[False, True],
1443 [False, False]])
1444
1445 Equivalently use the `MaskedArray` `mask` attribute.
1446
1447 >>> a.mask
1448 array([[False, True],
1449 [False, False]])
1450
1451 Result when mask == `nomask`
1452
1453 >>> b = ma.masked_array([[1,2],[3,4]])
1454 >>> b
1455 masked_array(
1456 data=[[1, 2],
1457 [3, 4]],
1458 mask=False,
1459 fill_value=999999)
1460 >>> ma.nomask
1461 False
1462 >>> ma.getmask(b) == ma.nomask
1463 True
1464 >>> b.mask == ma.nomask
1465 True
1466
1467 """
1468 return getattr(a, '_mask', nomask)

Callers 15

test_matrix_indexingMethod · 0.90
test_xtestCountMethod · 0.90
test_testCIMethod · 0.90
test_testCopySizeMethod · 0.90
test_testOddFeaturesMethod · 0.90
test_indexingMethod · 0.90
test_copyMethod · 0.90
test_count_funcMethod · 0.90
__call__Method · 0.85
__call__Method · 0.85
reduceMethod · 0.85

Calls

no outgoing calls

Tested by 12

test_matrix_indexingMethod · 0.72
test_xtestCountMethod · 0.72
test_testCIMethod · 0.72
test_testCopySizeMethod · 0.72
test_testOddFeaturesMethod · 0.72
test_indexingMethod · 0.72
test_copyMethod · 0.72
test_count_funcMethod · 0.72
approxFunction · 0.68
almostFunction · 0.68
assert_array_compareFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…