Mask should be a set of bools from comparison with a feature layer.
15336
def _xy_locs(mask):
  """"""
  y, x = mask.nonzero()
  return list(zip(x, y))
399348
def hasFeature(featureList, feature):
    
    for f in featureList:
        if f[0] == feature or Features[f[0]] == feature:
            return f[1]
309320
def normalize_mask(mask)
      mask = mask.dup
      mask.gsub!(/\*{2,}/, '*')
      parts = []
      remainder = nil

      if mask !~ /!/ && mask =~ /@/
        remainder = mask
        parts[0] = '*'
      else
        parts[0], remainder = mask.split(/!/, 2)
      end

      if remainder
        remainder.gsub!(/!/, '')
        parts[1..2] = remainder.split(/@/, 2)
      end
      parts[2].gsub!(/@/, '') if parts[2]

      (1..2).each { |i| parts[i] ||= '*' }
      return parts[0] + "!" + parts[1] + "@" + parts[2]
    end
193799
def get_mask(self, m):
        """"""
        mask = torch.ones((m, m, m, self.k_lf, self.k_lf, self.k_lf)).byte()
        for i, j, k in product(range(m), repeat=3):
            if len(set((i, j, k))) < 3:
                mask[i, j, k, :, :, :] = 0
        return mask
130791
function(image, x, y, options) {
        var result = false;
        var data = options.data;
        if (!data)
            return result;
        var mask = this._getImageMask(image, options);
        var imageMaskWidth = this._getMaskX(image.width);
        var maskShiftX = this._getMaskX(x);
        var maskShiftY = this._getMaskY(y);
        for (var i = 0; i < mask.length; i++) {
            if (!mask[i])
                continue;
            var maskX = maskShiftX + (i % imageMaskWidth);
            var maskY = maskShiftY + Math.floor(i / imageMaskWidth);
            var key = this._getIndexKey(maskX, maskY);
            this._addDataToIndex(key, options);
            result = true;
        }
        return result;
    }
502468
def maskQuality(self, umi, umi_quals):
        ''''''
        masked_umi = mask_umi(umi, umi_quals,
                              self.quality_encoding,
                              self.quality_filter_mask)
        if masked_umi != umi:
            self.read_counts['UMI masked'] += 1
            return masked_umi
        else:
            return umi
379808
def mask(self):
        
        if not hasattr(self, "_mask"):
            self._mask = Mask(self) if self.has_mask() else None
        return self._mask
887347
def is_bool_matrix(l):
    

    """
    if isinstance(l, np.ndarray):
        if l.ndim == 2 and (l.dtype == bool):
            return True
    return False
890497
def contour_mask(self, contour):
        
        # fill in new data
        new_data = np.zeros(self.data.shape)
        num_boundary = contour.boundary_pixels.shape[0]
        boundary_px_ij_swapped = np.zeros([num_boundary, 1, 2])
        boundary_px_ij_swapped[:, 0, 0] = contour.boundary_pixels[:, 1]
        boundary_px_ij_swapped[:, 0, 1] = contour.boundary_pixels[:, 0]
        cv2.fillPoly(
            new_data, pts=[
                boundary_px_ij_swapped.astype(
                    np.int32)], color=(
                BINARY_IM_MAX_VAL, BINARY_IM_MAX_VAL, BINARY_IM_MAX_VAL))
        orig_zeros = np.where(self.data == 0)
        new_data[orig_zeros[0], orig_zeros[1]] = 0
        return BinaryImage(new_data.astype(np.uint8), frame=self._frame)
45887
def validatefeatures(self,features):
        """"""
        validatedfeatures = []
        for feature in features:
            if isinstance(feature, int) or isinstance(feature, float):
                validatedfeatures.append( str(feature) )
            elif self.delimiter in feature and not self.sklearn:
                raise ValueError("Feature contains delimiter: " + feature)
            elif self.sklearn and isinstance(feature, str): #then is sparse added together
                validatedfeatures.append(feature)
            else:
                validatedfeatures.append(feature)
        return validatedfeatures
230498
def masked(a, b):
    

    if np.any([a.dtype.kind.startswith(c) for c in ['i', 'u', 'f', 'c']]):
        n = np.array([np.nan for i in range(len(a))])
    else:
        n = np.array([None for i in range(len(a))])
        # a = a.astype(object)
    return np.where(b, a, n)
578459
def buildMask(dqarr, bitvalue):
    
    return bitfield_to_boolean_mask(dqarr, bitvalue, good_mask_value=1,
                                    dtype=np.uint8)
787987
def local_attention1d_masked_decoder(x, kv_dim, heads_dim,
                                     feedforward_dim, hparams):
  """"""
  print(x)
  _, length_dim, model_dim = x.shape.dims
  for layer in range(hparams.num_decoder_layers):
    layer_name = "decoder_layer_%d" % layer
    with tf.variable_scope(layer_name):
      # Self attention layer
      length_per_split = mtf.tensor_dim_to_size_per_split(
          hparams.layout, hparams.mesh_shape, length_dim)
      x += layer_prepostprocess_dropout(
          mtf.layers.masked_local_attention_1d(
              mtf.layers.layer_norm(x, model_dim, name="layer_norm_att"),
              kv_dim,
              heads_dim,
              window_size=hparams.block_length,
              length_per_split=length_per_split,
              name="self_att"), hparams)
      # ffn layer
      x += layer_prepostprocess_dropout(
          mtf.layers.dense_relu_dense(
              mtf.layers.layer_norm(x, model_dim, name="layer_norm_ffn"),
              feedforward_dim,
              hparams.dropout,
              dropout_broadcast_dims=[length_dim]), hparams)

  output = mtf.layers.layer_norm(x, model_dim, name="final_layer_norm")
  return output
1044860
public void revertFeatures(@NonNull INDArray[] features, INDArray[] maskArrays) {
        for (int i = 0; i < features.length; i++) {
            INDArray mask = (maskArrays == null ? null : maskArrays[i]);
            revertFeatures(features[i], mask, i);
        }
    }
1252798
def set_regression_mask(self, v):
        """"""
        base = self._base
        index = np.arange(v.size())
        np.random.shuffle(index)
        ones = np.ones(v.size())
        ones[index[int(base._tr_fraction * v.size()):]] = 0
        base._mask = SparseArray.fromlist(ones)
447159
def mask_negative(self):
        """"""
        self.mask = np.logical_and(self.mask, ~(self.intensity < 0))
823055
def masked_mean(inputs, targets, mask_id=None):
  """"""
  inputs = [x.astype(np.float32) for x in inputs]
  # We assume all elements in the list contribute equally.
  # TODO(lukaszkaiser): remove this assumption (e.g., when masks differ).
  length = len(inputs)
  if mask_id is None:
    # TODO(lukaszkaiser): can we just divide the sum by length? XLA optimizes?
    return sum([np.mean(x) / length for x in inputs])
  unmask = [1.0 - np.equal(t, mask_id).astype(np.float32) for t in targets]
  return sum([np.sum(x * m) / (length * np.sum(m))
              for x, m in zip(inputs, unmask)])