Filters units that are in attack range of the unit in parameter
428071
def in_attack_range_of(self, unit: Unit, bonus_distance: Union[int, float] = 0) -> "Units":
        
        return self.filter(lambda x: unit.target_in_range(x, bonus_distance=bonus_distance))
761688
def validate(self):
        
        super(ByteSizeFilter, self).validate()

        # Get scale
        lower_val = str(self._value).lower()
        if any(lower_val.endswith(i) for i in self.UNITS):
            scale = self.UNITS[lower_val[-1]]
            self._value = self._value[:-1]
        else:
            scale = 1

        # Get float value
        try:
            self._value = float(self._value)
        except (ValueError, TypeError), exc:
            raise FilterError("Bad numerical value %r in %r (%s)" % (self._value, self._condition, exc))

        # Scale to bytes
        self._value = self._value * scale
98676
private void validateFilters() {
    Set<String> ids = new HashSet<String>();
    for (Filter filter : filters) {
      ids.add(filter.getId());
    }

    for(Metric metric : metrics) {
      if (metric.getFilter() != null && 
          !metric.getFilter().isEmpty() && 
          !ids.contains(metric.getFilter())) {
        throw new IllegalArgumentException(
            String.format("unrecognized filter id %s in metric %s",
                metric.getFilter(), metric.getId()));
      }
    }
  }
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;
        }
    }
454533
def filter(self, *args, **kwargs):
        """"""
        obj = kwargs.pop(self.object_property_name, None)
        if obj is not None:
            kwargs['object_hash'] = self.model._compute_hash(obj)
        return super().filter(*args, **kwargs)
72675
def do_filter(self, arg):
        """"""
        if arg == "list":
            msg.info("TEST CASE FILTERS")
            for f in self.curargs["tfilter"]:
                if f == "*":
                    msg.info("  * (default, matches all)")
                else:
                    msg.info("  " + f)
        elif arg not in self.curargs["tfilter"]:
            self.curargs["tfilter"].append(arg)
            self.do_filter("list")
262531
def apply_filter(x, filter=None, axis=0):
    """"""
    x = _as_array(x)
    if x.shape[axis] == 0:
        return x
    b, a = filter
    return signal.filtfilt(b, a, x, axis=axis)
1269412
function SetFilterRange ( $attribute, $min, $max, $exclude=false )
    {
        assert ( is_string($attribute) );
        assert ( is_numeric($min) );
        assert ( is_numeric($max) );
        assert ( $min<=$max );

        $this->_filters[] = array ( "type"=>SPH_FILTER_RANGE, "attr"=>$attribute, "exclude"=>$exclude, "min"=>$min, "max"=>$max );
    }
811052
def layer_norm_vars(filters):
  """"""
  scale = tf.get_variable(
      "layer_norm_scale", [filters], initializer=tf.ones_initializer())
  bias = tf.get_variable(
      "layer_norm_bias", [filters], initializer=tf.zeros_initializer())
  return scale, bias
942100
def filter(o)
      raise ArgumentError.new('Wrong type supplied to filter') unless Splib.type_of?(o, @type)
      do_filter(o)
    end
480798
def dynamize_scan_filter(self, scan_filter):
        
        d = None
        if scan_filter:
            d = {}
            for attr_name, op, value in scan_filter:
                if op == 'BETWEEN':
                    if isinstance(value, tuple):
                        avl = [self.dynamize_value(v) for v in value]
                    else:
                        msg = 'BETWEEN condition requires a tuple value'
                        raise TypeError(msg)
                elif op == 'NULL' or op == 'NOT_NULL':
                    avl = None
                elif isinstance(value, tuple):
                    msg = 'Tuple can only be supplied with BETWEEN condition'
                    raise TypeError(msg)
                else:
                    avl = [self.dynamize_value(value)]
            dd = {'ComparisonOperator': op}
            if avl:
                dd['AttributeValueList'] = avl
            d[attr_name] = dd
        return d
949887
def filter_formatter(kwargs, attr_map):
    
    params = _depluralise_filters_key(copy.copy(kwargs))
    params.update(_get_filter(sdk_filter=params.pop('filter', {}), attr_map=attr_map))
    return params
1192102
def highPassFilter(self, threshold):
        '''
        
        '''
        if not threshold:
            return
        rows, cols = self.img.shape
        tx = int(cols * threshold)
        ty = int(rows * threshold)
        # middle:
        crow, ccol = rows // 2, cols // 2
        # square in the middle to zero
        self.fshift[crow - tx:crow + tx, ccol - ty:ccol + ty] = 0
194372
function(target, filter) {
      _.each(slice.call(arguments, 2), function(source) {
        var prop, _results;
        _results = [];
        for (prop in source) {
          if (source[prop] !== void 0 && _.include(filter, prop)) {
            _results.push(target[prop] = source[prop]);
          } else {
            _results.push(void 0);
          }
        }
        return _results;
      });
      return target;
    }
391578
def filter_params(self, value):
        
        if value is None:
            return {}

        key = self.target
        if self.lookup_type is not None:
            key += '__' + self.lookup_type
        return { key: value }
1359684
def filters_from_args(self, args):
        ''''''
        filters = dict()
        remainder = []
        for arg in args:
            try:
                equals = arg.index('=')
                # anything ofthe form key-value is taken as a filter
                filters[arg[0:equals]] = arg[equals+1:];
            except ValueError:
                remainder.append(arg)
        return (filters,remainder)
1009560
function shouldFilter(filters, anno) {
  for (var i = filters.length - 1; i > -1; i--) {
    var filter = filters[i];
    if (filter.type === anno.type) {
      if (_.isEqual(filter.position, anno.position)) {
        if (anno.isA && anno.isA === 'Date') {
          var filterDate = new Date(filter.value), fieldDate = new Date(anno.typed.Date);
          if (filter.operator === '<') {
            return fieldDate < filterDate;
          } else if (filter.operator === '>') {
            return fieldDate > filterDate;
          } else {
            return filterDate === fieldDate;
          }
        }
      } else {
        return filter.value == anno.value;
      }
    }
  }
  return false;
}