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

Function getmask

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

1360
1361
1362def getmask(a):
1363 """
1364 Return the mask of a masked array, or nomask.
1365
1366 Return the mask of `a` as an ndarray if `a` is a `MaskedArray` and the
1367 mask is not `nomask`, else return `nomask`. To guarantee a full array
1368 of booleans of the same shape as a, use `getmaskarray`.
1369
1370 Parameters
1371 ----------
1372 a : array_like
1373 Input `MaskedArray` for which the mask is required.
1374
1375 See Also
1376 --------
1377 getdata : Return the data of a masked array as an ndarray.
1378 getmaskarray : Return the mask of a masked array, or full array of False.
1379
1380 Examples
1381 --------
1382 >>> import numpy.ma as ma
1383 >>> a = ma.masked_equal([[1,2],[3,4]], 2)
1384 >>> a
1385 masked_array(
1386 data=[[1, --],
1387 [3, 4]],
1388 mask=[[False, True],
1389 [False, False]],
1390 fill_value=2)
1391 >>> ma.getmask(a)
1392 array([[False, True],
1393 [False, False]])
1394
1395 Equivalently use the `MaskedArray` `mask` attribute.
1396
1397 >>> a.mask
1398 array([[False, True],
1399 [False, False]])
1400
1401 Result when mask == `nomask`
1402
1403 >>> b = ma.masked_array([[1,2],[3,4]])
1404 >>> b
1405 masked_array(
1406 data=[[1, 2],
1407 [3, 4]],
1408 mask=False,
1409 fill_value=999999)
1410 >>> ma.nomask
1411 False
1412 >>> ma.getmask(b) == ma.nomask
1413 True
1414 >>> b.mask == ma.nomask
1415 True
1416
1417 """
1418 return getattr(a, '_mask', nomask)
1419

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