Filter a network's rows or cols based on num_occur values being above a
  threshold (in absolute_value)
355971
def filter_threshold(df, inst_rc, threshold, num_occur=1):
  '''
  
  '''
  from copy import deepcopy

  inst_df = deepcopy(df['mat'])

  if inst_rc == 'col':
    inst_df = inst_df.transpose()

  inst_df = inst_df.abs()

  ini_rows = inst_df.index.values.tolist()

  inst_df[inst_df < threshold] = 0
  inst_df[inst_df >= threshold] = 1

  tmp_sum = inst_df.sum(axis=1)

  tmp_sum = tmp_sum[tmp_sum >= num_occur]

  keep_names = tmp_sum.index.values.tolist()

  if inst_rc == 'row':
    if len(keep_names) < len(ini_rows):
      df['mat'] = grab_df_subset(df['mat'], keep_rows=keep_names)

      if 'mat_up' in df:
        df['mat_up'] = grab_df_subset(df['mat_up'], keep_rows=keep_names)
        df['mat_dn'] = grab_df_subset(df['mat_dn'], keep_rows=keep_names)

      if 'mat_orig' in df:
        df['mat_orig'] = grab_df_subset(df['mat_orig'], keep_rows=keep_names)

  elif inst_rc == 'col':
    inst_df = inst_df.transpose()

    inst_rows = inst_df.index.values.tolist()
    inst_cols = keep_names

    df['mat'] = grab_df_subset(df['mat'], inst_rows, inst_cols)

    if 'mat_up' in df:
      df['mat_up'] = grab_df_subset(df['mat_up'], inst_rows, inst_cols)
      df['mat_dn'] = grab_df_subset(df['mat_dn'], inst_rows, inst_cols)

    if 'mat_orig' in df:
      df['mat_orig'] = grab_df_subset(df['mat_orig'], inst_rows, inst_cols)

  return df
192016
def filter_select_columns_intensity(df, prefix, columns):
    
    # Note: I use %s.+ (not %s.*) so it forces a match with the prefix string, ONLY if it is followed by something.
    return df.filter(regex='^(%s.+|%s)$' % (prefix, '|'.join(columns)) )
841573
def filter(self, table, vg_snapshots, filter_string):
        """"""
        query = filter_string.lower()
        return [vg_snapshot for vg_snapshot in vg_snapshots
                if query in vg_snapshot.name.lower()]
1061403
def filter_sum(self, inst_rc, threshold, take_abs=True):
    '''
    
    '''
    inst_df = self.dat_to_df()
    if inst_rc == 'row':
      inst_df = run_filter.df_filter_row_sum(inst_df, threshold, take_abs)
    elif inst_rc == 'col':
      inst_df = run_filter.df_filter_col_sum(inst_df, threshold, take_abs)
    self.df_to_dat(inst_df)
213868
def _mask_invalid(self, data, header):
        """"""
        invalid = da.logical_or(data == header['block5']["count_value_outside_scan_pixels"][0],
                                data == header['block5']["count_value_error_pixels"][0])
        return da.where(invalid, np.float32(np.nan), data)
1029413
def filter(self, table, mappings, filter_string):
        """"""
        q = filter_string.lower()
        return [mapping for mapping in mappings
                if q in mapping.ud.lower()]
145467
def _findRow(subNo, model):
    """"""
    items = model.findItems(str(subNo))
    if len(items) == 0:
        return None
    if len(items) > 1:
        raise IndexError("Too many items with sub number %s" % subNo)
    return items[0].row()
1337359
function filter(rows = [], filters = [], filterText, columns) {
  let filteredRows = rows.slice(0);
  if (filters.length === 0 && !filterText) {
    return filteredRows;
  }

  const textFilters = [
    ...(filterText ? [filterText.toLowerCase()] : []),
    ...filters.filter(f => f.textFilter).map(f => f.value),
  ];

  const valueFilters = filters.filter(f => f.valueFilter);

  // apply text filters across all columns
  if (textFilters.length > 0) {
    filteredRows = _.filter(rows, row => _.some(columns, (column) => {
      if (!column.searchable) {
        return false;
      }
      const normalized = String(_.get(row, column.key)).toLowerCase();
      return _.every(textFilters, f => normalized.indexOf(f) > -1);
    }));
  }

  // apply value filters on filterable columns
  if (valueFilters.length > 0) {
    const groups = _.groupBy(valueFilters, 'key');
    filteredRows = _.filter(filteredRows, row => _.every(
      groups,
      (groupFilters, groupKey) => {
        const value = _.get(row, groupKey);
        return _.some(groupFilters, f => f.value === value);
      }
    ));
  }

  return filteredRows;
}
776212
def clean(self,x):
        """"""
        return x[~np.any(np.isnan(x) | np.isinf(x),axis=1)]
485575
def filter_false_positive(df, process_time):
    
    result = []
    track = []
    count = 0
    for o in df['alerts']:
        count += 1
        if 'closedState' in o:
            if o['closedState'] != 'False Positive':
                if 'distinguishers' in o:
                    try:
                        if 'virus' in o['distinguishers']:
                            if o['distinguishers']['virus'] != 'fetestevent':
                                result.append(o)
                            else:
                                track.append(o)  # Track fetestevents that are skipped
                        else:
                            result.append(o)
                    except TypeError:
                        result.append(o)
                else:
                    result.append(o)
            else:
                track.append(o)  # Track false positives that are skipped
        elif 'distinguishers' in o:
            try:
                if 'virus' in o['distinguishers']:
                    if o['distinguishers']['virus'] != 'fetestevent':
                        result.append(o)
                    else:
                        track.append(o)  # Track fetestevents that are skipped
                else:
                    result.append(o)
            except TypeError:
                result.append(o)

    trackfile = open('tracking_fetest_' + process_time + '.txt', 'w')
    numskip = 1
    for item in track:
        trackfile.write("\n\n**** {:d}: Display ID {} ****\n\n{}".format(numskip, item['displayId'], item))
        numskip += 1
    return result
174486
def _match_net(self, net):
        """"""
        if self.network:
            return match_list(self.network, net)
        else:
            return True
1086307
def _filter_by_pattern(self, pattern):
        """"""
        try:
            _len = len(pattern)
        except TypeError:
            raise TypeError("pattern is not a list of Booleans. Got {}".format(
                type(pattern)))
        _filt_values = [d for i, d in enumerate(self._values) if pattern[i % _len]]
        _filt_datetimes = [d for i, d in enumerate(self.datetimes) if pattern[i % _len]]
        return _filt_values, _filt_datetimes
100663
def filter_N_top(self, inst_rc, N_top, rank_type='sum'):
    '''
    
    '''
    inst_df = self.dat_to_df()

    inst_df = run_filter.filter_N_top(inst_rc, inst_df, N_top, rank_type)

    self.df_to_dat(inst_df)
657658
def subn_filter(s, find, replace, count=0):
    """"""
    return re.gsub(find, replace, count, s)
516901
def get_value_by_row_col(self, row, col):
        
        if row < 0 or row >= self.nRows or col < 0 or col >= self.nCols:
            raise ValueError("The row or col must be >=0 and less than "
                             "nRows (%d) or nCols (%d)!" % (self.nRows, self.nCols))
        else:
            value = self.data[int(round(row))][int(round(col))]
            if value == self.noDataValue:
                return None
            else:
                return value
711909
private void filter(Vector3f acc) {
        float threshold = 15f;
        if (acc.x > threshold) {
            acc.x = threshold;
        } else if(acc.x < -threshold) {
            acc.x = -threshold;
        }
        if (acc.y > threshold) {
            acc.y = threshold;
        } else if(acc.y < -threshold) {
            acc.y = -threshold;
        }
        if (acc.z > threshold) {
            acc.z = threshold;
        } else if(acc.z < -threshold) {
            acc.z = -threshold;
        }
    }
561148
def filter_not_empty_values(value):
    """"""
    if not value:
        return None
    data = [x for x in value if x]
    if not data:
        return None
    return data