parameters: (self, mask, copy=False)
return_statement: return
docstring: Set the mask.
docstring_summary: Set the mask.
docstring_tokens: Set the mask .
function: def __setmask__(self, mask, copy=False):
          """Set the mask.
  
          """
          idtype = ndarray.__getattribute__(self, 'dtype')
          current_mask = ndarray.__getattribute__(self, '_mask')
          if mask is masked:
              mask = True
          # Make sure the mask is set
          if (current_mask is nomask):
              # Just don't do anything is there's nothing to do...
              if mask is nomask:
                  return
              current_mask = self._mask = make_mask_none(self.shape, idtype)
          # No named fields.........
          if idtype.names is None:
              # Hardmask: don't unmask the data
              if self._hardmask:
                  current_mask |= mask
              # Softmask: set everything to False
              else:
                  current_mask.flat = mask
          # Named fields w/ ............
          else:
              mdtype = current_mask.dtype
              mask = np.array(mask, copy=False)
              # Mask is a singleton
              if not mask.ndim:
                  # It's a boolean : make a record
                  if mask.dtype.kind == 'b':
                      mask = np.array(tuple([mask.item()]*len(mdtype)),
                                      dtype=mdtype)
                  # It's a record: make sure the dtype is correct
                  else:
                      mask = mask.astype(mdtype)
              # Mask is a sequence
              else:
                  # Make sure the new mask is a ndarray with the proper dtype
                  try:
                      mask = np.array(mask, copy=copy, dtype=mdtype)
                  # Or assume it's a sequence of bool/int
                  except TypeError:
                      mask = np.array([tuple([m] * len(mdtype)) for m in mask],
                                      dtype=mdtype)
              # Hardmask: don't unmask the data
              if self._hardmask:
                  for n in idtype.names:
                      current_mask[n] |= mask[n]
              # Softmask: set everything to False
              else:
                  current_mask.flat = mask
          # Reshape if needed
          if current_mask.shape:
              current_mask.shape = self.shape
          return
function_tokens: def __setmask__ ( self , mask , copy = False ) : idtype = ndarray . __getattribute__ ( self , 'dtype' ) current_mask = ndarray . __getattribute__ ( self , '_mask' ) if mask is masked : mask = True # Make sure the mask is set if ( current_mask is nomask ) : # Just don't do anything is there's nothing to do... if mask is nomask : return current_mask = self . _mask = make_mask_none ( self . shape , idtype ) # No named fields......... if idtype . names is None : # Hardmask: don't unmask the data if self . _hardmask : current_mask |= mask # Softmask: set everything to False else : current_mask . flat = mask # Named fields w/ ............ else : mdtype = current_mask . dtype mask = np . array ( mask , copy = False ) # Mask is a singleton if not mask . ndim : # It's a boolean : make a record if mask . dtype . kind == 'b' : mask = np . array ( tuple ( [ mask . item ( ) ] * len ( mdtype ) ) , dtype = mdtype ) # It's a record: make sure the dtype is correct else : mask = mask . astype ( mdtype ) # Mask is a sequence else : # Make sure the new mask is a ndarray with the proper dtype try : mask = np . array ( mask , copy = copy , dtype = mdtype ) # Or assume it's a sequence of bool/int except TypeError : mask = np . array ( [ tuple ( [ m ] * len ( mdtype ) ) for m in mask ] , dtype = mdtype ) # Hardmask: don't unmask the data if self . _hardmask : for n in idtype . names : current_mask [ n ] |= mask [ n ] # Softmask: set everything to False else : current_mask . flat = mask # Reshape if needed if current_mask . shape : current_mask . shape = self . shape return