Given `arrs` is [a,b,...] and `mask`index - return[(a[mask],a[~mask]),(b[mask],b[~mask]),...].
423345
def arrays_split(mask:NPArrayMask, *arrs:NPArrayableList)->SplitArrayList:
    ""
    assert all([len(arr)==len(arrs[0]) for arr in arrs]), 'All arrays should have same length'
    mask = array(mask)
    return list(zip(*[(a[mask],a[~mask]) for a in map(np.array, arrs)]))
868790
def _compute(self, arrays, dates, assets, mask):
        
        return super(NumExprFilter, self)._compute(
            arrays,
            dates,
            assets,
            mask,
        ) & mask
911155
def _apply_mask(
    data: np.ndarray,
    encoded_fill_values: list,
    decoded_fill_value: Any,
    dtype: Any,
) -> np.ndarray:
    """"""
    data = np.asarray(data, dtype=dtype)
    condition = False
    for fv in encoded_fill_values:
        condition |= data == fv
    return np.where(condition, decoded_fill_value, data)
847348
protected int getIndexFromMap(int[] maskMap, int index) {
        if (index < 0 || index >= maskMap.length)
            throw new IndexOutOfBoundsException(
                    "The given index is beyond the bounds of the matrix");
        int newIndex = maskMap[index];
        if (newIndex < 0 ||
            maskMap == rowMaskMap && newIndex >= matrix.rows() ||
            maskMap == colMaskMap && newIndex >= matrix.columns())
            throw new IndexOutOfBoundsException(
                    "The mapped index is beyond the bounds of the base matrix");
        return newIndex;
    }
567342
def asMaskedArray(self):
        
        return ma.masked_array(data=self.data, mask=self.mask, fill_value=self.fill_value)
751698
def _calc_mask(self):
    """"""
    mask = []
    for row in self._constraints:
      mask.append(tuple(x is None for x in row))
    return tuple(mask)
977049
function indexesOf(a, elt) {
  var ret = [], index = 0;
  while ((index = a.indexOf(elt, index)) !== -1) {
    ret.push(index++);
  }
  return ret;
}
284704
def _tomask(self, indices, element):
        
        """
        element = self._parse_element(element, single=True)
        indices = self._parse_indices(indices)
        N = sp.shape(self[element + '.all'])[0]
        ind = sp.array(indices, ndmin=1)
        mask = sp.zeros((N, ), dtype=bool)
        mask[ind] = True
        return mask
410708
def mask2spans(mask, index=None):
    """"""
    index = list(range(len(mask))) if index is None else index

    mask = pd.Series(mask)
    mask = mask.astype(int).fillna(0).diff().fillna(0)
    starts = list(index[mask > 0])
    stops = list(index[mask < 0])
    if len(stops) == len(starts) - 1:
        stops += [index.values[-1]]
    spans = join_spans(join_spans(zip(starts, stops)))
    return spans
1128203
function (arr, val) {

            debug('Finding all indices...');
            debug('Array: %o', arr);

            let indexes = [];

            for (let i = 0; i < arr.length; i++) {

                const
                    camelCaseVal = camelCase(val),
                    camelCaseKey = camelCase(arr[i]);

                if (arr[i] === val || camelCaseKey === camelCaseVal) {

                    debug('Matched index: %s', i);

                    indexes.push(i);
                }
            }

            debug('Found indices: %o', indexes);

            return indexes;
        }
621723
def spaced_indexes(len_, n, trunc=False):
    

    if n is None:
        return np.arange(len_)
    all_indexes = np.arange(len_)
    if trunc:
        n = min(len_, n)
    if n == 0:
        return np.empty(0)
    stride = len_ // n
    try:
        indexes = all_indexes[0:-1:stride]
    except ValueError:
        raise ValueError('cannot slice list of len_=%r into n=%r parts' % (len_, n))
    return indexes
195548
def pattern_of(index):
    ''''''
    return np.array([[index & 2**0,index & 2**1,index & 2**2],
                     [index & 2**3,index & 2**4,index & 2**5],
                     [index & 2**6,index & 2**7,index & 2**8]], bool)
643765
def get_array_indices(self):
        """"""

        for token in self.tokens:
            if isinstance(token, SquareBrackets):
                # Use [1:-1] index to discard the square brackets
                yield token.tokens[1:-1]
315760
function mode(arr) {
              return arr.sort((a, b) =>
                arr.filter((v) => v === a).length
                    - arr.filter((v) => v === b).length
              ).pop();
            }
178685
def imageToBoolMasks(arr):
    ''''''
    assert arr.dtype == np.uint8, 'image needs to be dtype=uint8'
    masks = np.unpackbits(arr).reshape(*arr.shape, 8)
    return np.swapaxes(masks, 2, 0)
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
847310
def mask_reduce(mask):
    
    mask = mask.copy()
    for i in range(len(mask.shape)):
        a = mask.copy()
        j = list(range(len(mask.shape)))
        j.remove(i)
        j = tuple(j)
        a = a.max(axis=j, keepdims=True)
        idx = [slice(None)] * len(mask.shape)
        a = a.flatten()
        idx[i] = [k for k in range(len(a)) if a[k]]
        mask = mask[tuple(idx)]
    return mask