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)
| 1409 | |
| 1410 | |
| 1411 | def 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) |
no outgoing calls
searching dependent graphs…