numpy.ma.flatten_mask#

ma.flatten_mask(mask)[source]#

Returns a completely flattened version of the mask, where nested fields are collapsed.

Parameters:
maskarray_like

Input array, which will be interpreted as booleans.

Returns:
flattened_maskndarray of bools

The flattened input.

Examples

>>> import numpy as np
>>> mask = np.array([0, 0, 1])
>>> np.ma.flatten_mask(mask)
array([False, False,  True])
>>> mask = np.array([(0, 0), (0, 1)], dtype=[('a', bool), ('b', bool)])
>>> np.ma.flatten_mask(mask)
array([False, False, False,  True])
>>> mdtype = [('a', bool), ('b', [('ba', bool), ('bb', bool)])]
>>> mask = np.array([(0, (0, 0)), (0, (0, 1))], dtype=mdtype)
>>> np.ma.flatten_mask(mask)
array([False, False, False, False, False,  True])