Return a boolean mask of the given shape, filled with False. This function returns a boolean ndarray with all entries False, that can be used in common mask manipulations. If a complex dtype is specified, the type of each field is converted to a boolean type. Parameters --
(newshape, dtype=None)
| 1696 | |
| 1697 | |
| 1698 | def make_mask_none(newshape, dtype=None): |
| 1699 | """ |
| 1700 | Return a boolean mask of the given shape, filled with False. |
| 1701 | |
| 1702 | This function returns a boolean ndarray with all entries False, that can |
| 1703 | be used in common mask manipulations. If a complex dtype is specified, the |
| 1704 | type of each field is converted to a boolean type. |
| 1705 | |
| 1706 | Parameters |
| 1707 | ---------- |
| 1708 | newshape : tuple |
| 1709 | A tuple indicating the shape of the mask. |
| 1710 | dtype : {None, dtype}, optional |
| 1711 | If None, use a MaskType instance. Otherwise, use a new datatype with |
| 1712 | the same fields as `dtype`, converted to boolean types. |
| 1713 | |
| 1714 | Returns |
| 1715 | ------- |
| 1716 | result : ndarray |
| 1717 | An ndarray of appropriate shape and dtype, filled with False. |
| 1718 | |
| 1719 | See Also |
| 1720 | -------- |
| 1721 | make_mask : Create a boolean mask from an array. |
| 1722 | make_mask_descr : Construct a dtype description list from a given dtype. |
| 1723 | |
| 1724 | Examples |
| 1725 | -------- |
| 1726 | >>> import numpy as np |
| 1727 | >>> import numpy.ma as ma |
| 1728 | >>> ma.make_mask_none((3,)) |
| 1729 | array([False, False, False]) |
| 1730 | |
| 1731 | Defining a more complex dtype. |
| 1732 | |
| 1733 | >>> dtype = np.dtype({'names':['foo', 'bar'], |
| 1734 | ... 'formats':[np.float32, np.int64]}) |
| 1735 | >>> dtype |
| 1736 | dtype([('foo', '<f4'), ('bar', '<i8')]) |
| 1737 | >>> ma.make_mask_none((3,), dtype=dtype) |
| 1738 | array([(False, False), (False, False), (False, False)], |
| 1739 | dtype=[('foo', '|b1'), ('bar', '|b1')]) |
| 1740 | |
| 1741 | """ |
| 1742 | if dtype is None: |
| 1743 | result = np.zeros(newshape, dtype=MaskType) |
| 1744 | else: |
| 1745 | result = np.zeros(newshape, dtype=make_mask_descr(dtype)) |
| 1746 | return result |
| 1747 | |
| 1748 | |
| 1749 | def _recursive_mask_or(m1, m2, newmask): |
no test coverage detected
searching dependent graphs…