def _matrix_mask(data, mask):
 if (mask is None):
  mask = np.zeros(data.shape, np.bool)
 if isinstance(mask, np.ndarray):
  if (mask.shape != data.shape):
   raise ValueError('Mask must have the same shape as data.')
  mask = pd.DataFrame(mask, index=data.index, columns=data.columns, dtype=np.bool)
 elif isinstance(mask, pd.DataFrame):
  if ((not mask.index.equals(data.index)) and mask.columns.equals(data.columns)):
   err = 'Mask must have the same index and columns as data.'
   raise ValueError(err)
 mask = (mask | pd.isnull(data))
 return mask

def _matrix_mask ( data , mask ) : if ( mask is None ) : mask = np . zeros ( data . shape , np . bool ) if isinstance ( mask , np . ndarray ) : if ( mask . shape != data . shape ) : raise ValueError ( 'Mask must have the same shape as data.' ) mask = pd . DataFrame ( mask , index = data . index , columns = data . columns , dtype = np . bool ) elif isinstance ( mask , pd . DataFrame ) : if ( ( not mask . index . equals ( data . index ) ) and mask . columns . equals ( data . columns ) ) : err = 'Mask must have the same index and columns as data.' raise ValueError ( err ) mask = ( mask | pd . isnull ( data ) ) return mask
ensure that data and mask are compatabile and add missing values .