Generic function for maping a filtering operation over images.

        Parameters
        ----------
        filter : string
            Which filter to use.

        size : int or tuple
            Size parameter for filter.
427223
def _image_filter(self, filter=None, size=2):
        
        from numpy import isscalar
        from scipy.ndimage.filters import median_filter, uniform_filter

        FILTERS = {
            'median': median_filter,
            'uniform': uniform_filter
        }

        func = FILTERS[filter]

        mode = self.mode
        value_shape = self.value_shape
        ndims = len(value_shape)

        if ndims == 3 and isscalar(size) == 1:
            size = [size, size, size]

        if ndims == 3 and size[2] == 0:
            def filter_(im):
                if mode == 'spark':
                    im.setflags(write=True)
                else:
                    im = im.copy()
                for z in arange(0, value_shape[2]):
                    im[:, :, z] = func(im[:, :, z], size[0:2])
                return im
        else:
            filter_ = lambda x: func(x, size)

        return self.map(lambda v: filter_(v), value_shape=self.value_shape)
983075
def wrap_filters(filters):
  
  def combined_filter(x):
    for filt in filters:
      if not filt(x):
        return False
    return True
  return combined_filter
256621
public static autoscaleprofile[] get_filtered(nitro_service service, String filter) throws Exception{
		autoscaleprofile obj = new autoscaleprofile();
		options option = new options();
		option.set_filter(filter);
		autoscaleprofile[] response = (autoscaleprofile[]) obj.getfiltered(service, option);
		return response;
	}
552374
def convolutional_layer_series(initial_size, layer_sequence):
    
    size = initial_size

    for filter_size, padding, stride in layer_sequence:
        size = convolution_size_equation(size, filter_size, padding, stride)

    return size
1272617
def tis2hw(size:Union[int,TensorImageSize]) -> Tuple[int,int]:
    ""
    if type(size) is str: raise RuntimeError("Expected size to be an int or a tuple, got a string.")
    return listify(size, 2) if isinstance(size, int) else listify(size[-2:],2)
1369392
def _get_filter(self, features):
        

        # This chops the features up into smaller lists so the api can handle them
        for ip_batch in (features['ips'][pos:pos + self.ip_query_batch_size]
                         for pos in six.moves.range(0, len(features['ips']), self.ip_query_batch_size)):
            # Query for each chunk and add it to the filter list
            query = {'ips': ip_batch, 'ports': features['ports']}
            self.filter['ips'] += self._send_features(query)['ips']
937977
def _fits_in_width_predicate(self, point_size):
        
        def predicate(line):
            """
            Return |True| if *line* fits in this fitter when rendered at
            *point_size*.
            """
            cx = _rendered_size(line.text, point_size, self._font_file)[0]
            return cx <= self._width

        return predicate
443259
def cmd_filter(args):
    
    check_output_format(args.output, args.count)

    img = Image.open(args.input)
    width, height = img.size

    if args.state is not None:
        markov = load(MarkovImage, args.state, args)
    else:
        args.state = ()
        if args.type == JSON:
            storage = JsonStorage(settings=args.settings)
        else:
            storage = SqliteStorage(settings=args.settings)
        markov = MarkovImage.from_storage(storage)
        read([args.input], markov, args.progress, False)

    args.level = min(args.level, markov.levels - 1) - 1

    if args.level < 0:
        args.level = -1
        scale = markov.scanner.min_size
        width, height = width // scale, height // scale
        start = None
    else:
        scale = reduce(
            lambda x, y: x * y,
            islice(markov.scanner.level_scale, args.level, markov.levels),
            1
        )
        width, height = width // scale, height // scale
        start = img.resize((width, height), markov.scanner.scale)

    for fname in outfiles(markov, args.output,
                          args.count, args.progress, args.level + 1):
        img = markov(
            width, height,
            state_size=args.state_size,
            start_level=args.level,
            start_image=start
        )
        save_image(img, fname)
921164
function fileFilter(filter) {
  if (filter) {
     if (typeof filter === 'string') {
        var regex = new RegExp(filter);
        return function(filePath) { return regex.test(filePath); }
     }
     else if (filter instanceof RegExp)
        return function(filePath) { return filter.test(filePath); }
     else {   // must be a function itself
        return filter;
     }
   }
   else  // none, return "pass all"
      return function() { return true; };
}
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
324773
public void initFilter(FunDapterFilter<T> filter) {

        if (filter == null)
            throw new IllegalArgumentException("Cannot pass a null filter to FunDapter");

        this.funDapterFilter = filter;

        mFilter = new Filter() {

            @Override
            protected void publishResults(CharSequence constraint, FilterResults results) {

                @SuppressWarnings("unchecked") List<T> list = (List<T>) results.values;

                if (results.count == 0) {
                    resetData();
                } else {
                    mDataItems = list;
                }

                notifyDataSetChanged();
            }

            @Override
            protected FilterResults performFiltering(CharSequence constraint) {

                FilterResults results = new FilterResults();
                if (constraint == null || constraint.length() == 0) {

                    // No constraint - no point in filtering.
                    results.values = mOrigDataItems;
                    results.count = mOrigDataItems.size();
                } else {
                    // Perform the filtering operation

                    List<T> filter =
                            funDapterFilter.filter(constraint.toString(), mOrigDataItems);

                    results.count = filter.size();
                    results.values = filter;

                }

                return results;
            }
        };
    }
1297038
def filter_(stream_spec, filter_name, *args, **kwargs):
    
    return filter(stream_spec, filter_name, *args, **kwargs)
954799
function(filter) {
      return u(array.filter.call(this, function(el, index) {
        return /^f/.test(typeof filter) ? filter(index, el) : u(el).is(filter);
      }));
    }
441
def _homogenize_data_filter(dfilter):
    
    if isinstance(dfilter, tuple) and (len(dfilter) == 1):
        dfilter = (dfilter[0], None)
    if (dfilter is None) or (dfilter == (None, None)) or (dfilter == (None,)):
        dfilter = (None, None)
    elif isinstance(dfilter, dict):
        dfilter = (dfilter, None)
    elif isinstance(dfilter, (list, str)) or (
        isinstance(dfilter, int) and (not isinstance(dfilter, bool))
    ):
        dfilter = (None, dfilter if isinstance(dfilter, list) else [dfilter])
    elif isinstance(dfilter[0], dict) or (
        (dfilter[0] is None) and (not isinstance(dfilter[1], dict))
    ):
        pass
    else:
        dfilter = (dfilter[1], dfilter[0])
    return dfilter
1273967
public int getCacheIdsSize(boolean filter) {
        if (filter == CacheOnDisk.FILTER) {
            return htod.getCacheIdsSize(filter) - htod.invalidationBuffer.size();
        } else {
            return htod.getCacheIdsSize(filter);
        }

    }
322877
def filter(self, filter):
        
        new_query_set = self.clone()
        new_query_set.query.add_filter(filter)
        
        return new_query_set
1136743
def addFilter(self, filter):
        
        self.FILTERS.append(filter)
        return "FILTER#{}".format(len(self.FILTERS) - 1)