def __setmask__(self, mask, copy=False):
idtype = ndarray.__getattribute__(self, '<STR_LIT>')<EOL>current_mask = ndarray.__getattribute__(self, '<STR_LIT>')<EOL>if mask is masked:<EOL><INDENT>mask = True<EOL><DEDENT>if (current_mask is nomask):<EOL><INDENT>if mask is nomask:<EOL><INDENT>return<EOL><DEDENT>current_mask = self._mask = make_mask_none(self.shape, idtype)<EOL><DEDENT>if idtype.names is None:<EOL><INDENT>if self._hardmask:<EOL><INDENT>current_mask |= mask<EOL><DEDENT>elif isinstance(mask, (int, float, np.bool_, np.number)):<EOL><INDENT>current_mask[...] = mask<EOL><DEDENT>else:<EOL><INDENT>current_mask.flat = mask<EOL><DEDENT><DEDENT>else:<EOL><INDENT>mdtype = current_mask.dtype<EOL>mask = np.array(mask, copy=False)<EOL>if not mask.ndim:<EOL><INDENT>if mask.dtype.kind == '<STR_LIT:b>':<EOL><INDENT>mask = np.array(tuple([mask.item()]*len(mdtype)),<EOL>dtype=mdtype)<EOL><DEDENT>else:<EOL><INDENT>mask = mask.astype(mdtype)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>mask = np.array(mask, copy=copy, dtype=mdtype)<EOL><DEDENT>except TypeError:<EOL><INDENT>mask = np.array([tuple([m] * len(mdtype)) for m in mask],<EOL>dtype=mdtype)<EOL><DEDENT><DEDENT>if self._hardmask:<EOL><INDENT>for n in idtype.names:<EOL><INDENT>current_mask[n] |= mask[n]<EOL><DEDENT><DEDENT>elif isinstance(mask, (int, float, np.bool_, np.number)):<EOL><INDENT>current_mask[...] = mask<EOL><DEDENT>else:<EOL><INDENT>current_mask.flat = mask<EOL><DEDENT><DEDENT>if current_mask.shape:<EOL><INDENT>current_mask.shape = self.shape<EOL><DEDENT>return<EOL>
Set the mask.