Get the mask for the three-way overlaps matrix O, which is 0 when
        indices i,j,k are not unique
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
146023
private static TileMatrix getTileMatrixAtLengthIndex(
			List<TileMatrix> tileMatrices, int index) {
		return tileMatrices.get(tileMatrices.size() - index - 1);
	}
1200663
def masked(self) -> np.ndarray:
        """"""
        arr = self[:]
        arr.shape = self.shape
        arr = wt_kit.share_nans(arr, *self.parent.channels)[0]
        return np.nanmean(
            arr, keepdims=True, axis=tuple(i for i in range(self.ndim) if self.shape[i] == 1)
        )
222340
def log_of_array_ignoring_zeros(M):
    
    log_M = M.copy()
    mask = log_M > 0
    log_M[mask] = np.log(log_M[mask])
    return log_M
651300
def get_interleave_mask():
    

    nodemask = nodemask_t()
    bitmask = libnuma.numa_get_interleave_mask()
    libnuma.copy_bitmask_to_nodemask(bitmask, byref(nodemask))
    libnuma.numa_bitmask_free(bitmask)

    return numa_nodemask_to_set(nodemask)
793170
static int applyMaskPenaltyRule3(ByteMatrix matrix) {
    int numPenalties = 0;
    byte[][] array = matrix.getArray();
    int width = matrix.getWidth();
    int height = matrix.getHeight();
    for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
        byte[] arrayY = array[y];  // We can at least optimize this access
        if (x + 6 < width &&
            arrayY[x] == 1 &&
            arrayY[x + 1] == 0 &&
            arrayY[x + 2] == 1 &&
            arrayY[x + 3] == 1 &&
            arrayY[x + 4] == 1 &&
            arrayY[x + 5] == 0 &&
            arrayY[x + 6] == 1 &&
            (isWhiteHorizontal(arrayY, x - 4, x) || isWhiteHorizontal(arrayY, x + 7, x + 11))) {
          numPenalties++;
        }
        if (y + 6 < height &&
            array[y][x] == 1 &&
            array[y + 1][x] == 0 &&
            array[y + 2][x] == 1 &&
            array[y + 3][x] == 1 &&
            array[y + 4][x] == 1 &&
            array[y + 5][x] == 0 &&
            array[y + 6][x] == 1 &&
            (isWhiteVertical(array, x, y - 4, y) || isWhiteVertical(array, x, y + 7, y + 11))) {
          numPenalties++;
        }
      }
    }
    return numPenalties * N3;
  }
862886
function tril(A, k) {
    if (k === void 0) { k = 0; }
    if (A.shape.length !== 2) {
        throw new Error('Input is not matrix');
    }
    var copyA = A.clone();
    for (var i = 0; i < copyA.shape[0]; i++) {
        for (var j = 0; j < copyA.shape[1]; j++) {
            if (i < j - k) {
                copyA.set(i, j, 0);
            }
        }
    }
    return copyA;
}
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
755186
def get_xy_ma(bma, gt, stride=1, origmask=True, newmask=None):
    
    pX = np.arange(0, bma.shape[1], stride)
    pY = np.arange(0, bma.shape[0], stride)
    psamp = np.meshgrid(pX, pY)
    #if origmask:
    #    psamp = np.ma.array(psamp, mask=np.ma.getmaskarray(bma), fill_value=0)
    mX, mY = pixelToMap(psamp[0], psamp[1], gt)
    mask = None
    if origmask:
        mask = np.ma.getmaskarray(bma)[::stride]
    if newmask is not None:
        mask = newmask[::stride]
    mX = np.ma.array(mX, mask=mask, fill_value=0)
    mY = np.ma.array(mY, mask=mask, fill_value=0)
    return mX, mY
999641
def where(self, within_of=None, inplace=False, **kwargs):
        """"""
        masks = super(System, self).where(inplace=inplace, **kwargs)
        
        def index_to_mask(index, n):
            val = np.zeros(n, dtype='bool')
            val[index] = True
            return val
        
        def masks_and(dict1, dict2):
            return {k: dict1[k] & index_to_mask(dict2[k], len(dict1[k])) for k in dict1 }
        
        if within_of is not None:
            if self.box_vectors is None:
                raise Exception('Only periodic distance supported')
            thr, ref = within_of
            
            if isinstance(ref, int):
                a = self.r_array[ref][np.newaxis, np.newaxis, :] # (1, 1, 3,)
            elif len(ref) == 1:
                a = self.r_array[ref][np.newaxis, :] # (1, 1, 3)
            else:
                a = self.r_array[ref][:, np.newaxis, :] # (2, 1, 3)
            
            b = self.r_array[np.newaxis, :, :]
            dist = periodic_distance(a, b,
                                     periodic=self.box_vectors.diagonal())
            
            atoms = (dist <= thr).sum(axis=0, dtype='bool')
            m = self._propagate_dim(atoms, 'atom')
            masks = masks_and(masks, m)
        
        return masks
813014
def _build_mask(self):
        """"""
        self.mask = torch.ones(self.d, self.d).byte()
        for ci in self.c_data.values():
            si, ei = ci["start_index"], ci["end_index"]
            for cj in self.c_data.values():
                sj, ej = cj["start_index"], cj["end_index"]

                # Check if ci and cj are part of the same maximal clique
                # If so, mask out their corresponding blocks in O^{-1}
                if len(ci["max_cliques"].intersection(cj["max_cliques"])) > 0:
                    self.mask[si:ei, sj:ej] = 0
                    self.mask[sj:ej, si:ei] = 0
506705
def get_shape_mask(self, shape_obj):
        
        wd, ht = self.get_size()
        yi = np.mgrid[:ht].reshape(-1, 1)
        xi = np.mgrid[:wd].reshape(1, -1)
        pts = np.asarray((xi, yi)).T
        contains = shape_obj.contains_pts(pts)
        return contains
691810
function initMasks() {
	var i, mask,
	    result = new Uint8Array( 0x10000 );

	for ( i = 0; i < 0x10000; i++ ) {
		mask = 3;
		if ( i & 0x2 ) {
			// right
			mask <<= 2;
		}
		if ( i & 0x40 ) {
			// bottom
			mask <<= 4;
		}

		result[ i ] = mask;
	}

	return result;
}
751698
def _calc_mask(self):
    """"""
    mask = []
    for row in self._constraints:
      mask.append(tuple(x is None for x in row))
    return tuple(mask)
38910
def generate_threshold_mask(hist):
    '''
    '''
    masked_array = np.ma.masked_values(hist, 0)
    masked_array = np.ma.masked_greater(masked_array, 10 * np.ma.median(hist))
    logging.info('Masking %d pixel(s)', np.ma.count_masked(masked_array))
    return np.ma.getmaskarray(masked_array)
133184
def mask(self):
        '''
        

        '''

        return np.array(list(set(np.concatenate([self.outmask, self.badmask,
                        self.transitmask, self.nanmask]))), dtype=int)
114316
private static double coverRadius(double[][] matrix, int[] idx, int i) {
    final int idx_i = idx[i];
    final double[] row_i = matrix[i];
    double m = 0;
    for(int j = 0; j < row_i.length; j++) {
      if(i != j && idx_i == idx[j]) {
        final double d = row_i[j];
        m = d > m ? d : m;
      }
    }
    return m;
  }