parameters: (mask)
return_statement: return np.array([_ for _ in flattened], dtype=bool)
docstring: Returns a completely flattened version of the mask, where nested fields
      are collapsed.
  
      Parameters
      ----------
      mask : array_like
          Input array, which will be interpreted as booleans.
  
      Returns
      -------
      flattened_mask : ndarray of bools
          The flattened input.
  
      Examples
      --------
      >>> mask = np.array([0, 0, 1], dtype=np.bool)
      >>> flatten_mask(mask)
      array([False, False,  True], dtype=bool)
  
      >>> mask = np.array([(0, 0), (0, 1)], dtype=[('a', bool), ('b', bool)])
      >>> flatten_mask(mask)
      array([False, False, False,  True], dtype=bool)
  
      >>> mdtype = [('a', bool), ('b', [('ba', bool), ('bb', bool)])]
      >>> mask = np.array([(0, (0, 0)), (0, (0, 1))], dtype=mdtype)
      >>> flatten_mask(mask)
      array([False, False, False, False, False,  True], dtype=bool)
docstring_summary: Returns a completely flattened version of the mask, where nested fields
      are collapsed.
docstring_tokens: Returns a completely flattened version of the mask where nested fields are collapsed .
function: def flatten_mask(mask):
      """
      Returns a completely flattened version of the mask, where nested fields
      are collapsed.
  
      Parameters
      ----------
      mask : array_like
          Input array, which will be interpreted as booleans.
  
      Returns
      -------
      flattened_mask : ndarray of bools
          The flattened input.
  
      Examples
      --------
      >>> mask = np.array([0, 0, 1], dtype=np.bool)
      >>> flatten_mask(mask)
      array([False, False,  True], dtype=bool)
  
      >>> mask = np.array([(0, 0), (0, 1)], dtype=[('a', bool), ('b', bool)])
      >>> flatten_mask(mask)
      array([False, False, False,  True], dtype=bool)
  
      >>> mdtype = [('a', bool), ('b', [('ba', bool), ('bb', bool)])]
      >>> mask = np.array([(0, (0, 0)), (0, (0, 1))], dtype=mdtype)
      >>> flatten_mask(mask)
      array([False, False, False, False, False,  True], dtype=bool)
  
      """
      #
      def _flatmask(mask):
          "Flatten the mask and returns a (maybe nested) sequence of booleans."
          mnames = mask.dtype.names
          if mnames:
              return [flatten_mask(mask[name]) for name in mnames]
          else:
              return mask
      #
      def _flatsequence(sequence):
          "Generates a flattened version of the sequence."
          try:
              for element in sequence:
                  if hasattr(element, '__iter__'):
                      for f in _flatsequence(element):
                          yield f
                  else:
                      yield element
          except TypeError:
              yield sequence
      #
      mask = np.asarray(mask)
      flattened = _flatsequence(_flatmask(mask))
      return np.array([_ for _ in flattened], dtype=bool)
function_tokens: def flatten_mask ( mask ) : # def _flatmask ( mask ) : "Flatten the mask and returns a (maybe nested) sequence of booleans." mnames = mask . dtype . names if mnames : return [ flatten_mask ( mask [ name ] ) for name in mnames ] else : return mask # def _flatsequence ( sequence ) : "Generates a flattened version of the sequence." try : for element in sequence : if hasattr ( element , '__iter__' ) : for f in _flatsequence ( element ) : yield f else : yield element except TypeError : yield sequence # mask = np . asarray ( mask ) flattened = _flatsequence ( _flatmask ( mask ) ) return np . array ( [ _ for _ in flattened ] , dtype = bool )