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

Function is_mask

numpy/ma/core.py:1528–1594  ·  view source on GitHub ↗

Return True if m is a valid, standard mask. This function does not check the contents of the input, only that the type is MaskType. In particular, this function returns False if the mask has a flexible dtype. Parameters ---------- m : array_like Array to test.

(m)

Source from the content-addressed store, hash-verified

1526
1527
1528def is_mask(m):
1529 """
1530 Return True if m is a valid, standard mask.
1531
1532 This function does not check the contents of the input, only that the
1533 type is MaskType. In particular, this function returns False if the
1534 mask has a flexible dtype.
1535
1536 Parameters
1537 ----------
1538 m : array_like
1539 Array to test.
1540
1541 Returns
1542 -------
1543 result : bool
1544 True if `m.dtype.type` is MaskType, False otherwise.
1545
1546 See Also
1547 --------
1548 ma.isMaskedArray : Test whether input is an instance of MaskedArray.
1549
1550 Examples
1551 --------
1552 >>> import numpy as np
1553 >>> import numpy.ma as ma
1554 >>> m = ma.masked_equal([0, 1, 0, 2, 3], 0)
1555 >>> m
1556 masked_array(data=[--, 1, --, 2, 3],
1557 mask=[ True, False, True, False, False],
1558 fill_value=0)
1559 >>> ma.is_mask(m)
1560 False
1561 >>> ma.is_mask(m.mask)
1562 True
1563
1564 Input must be an ndarray (or have similar attributes)
1565 for it to be considered a valid mask.
1566
1567 >>> m = [False, True, False]
1568 >>> ma.is_mask(m)
1569 False
1570 >>> m = np.array([False, True, False])
1571 >>> m
1572 array([False, True, False])
1573 >>> ma.is_mask(m)
1574 True
1575
1576 Arrays with complex dtypes don't return True.
1577
1578 >>> dtype = np.dtype({'names':['monty', 'pithon'],
1579 ... 'formats':[bool, bool]})
1580 >>> dtype
1581 dtype([('monty', '|b1'), ('pithon', '|b1')])
1582 >>> m = np.array([(True, False), (False, True), (True, False)],
1583 ... dtype=dtype)
1584 >>> m
1585 array([( True, False), (False, True), ( True, False)],

Callers 1

mask_orFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…