Construct string representing state of filter_fn
            Used to cache filtered variants or effects uniquely depending on filter fn values
974924
def _hash_filter_fn(self, filter_fn, **kwargs):
        
        filter_fn_name = self._get_function_name(filter_fn, default="filter-none")
        logger.debug("Computing hash for filter_fn: {} with kwargs {}".format(filter_fn_name, str(dict(**kwargs))))
        # hash function source code
        fn_source = str(dill.source.getsource(filter_fn))
        pickled_fn_source = pickle.dumps(fn_source) ## encode as byte string
        hashed_fn_source = int(hashlib.sha1(pickled_fn_source).hexdigest(), 16) % (10 ** 11)
        # hash kwarg values
        kw_dict = dict(**kwargs)
        kw_hash = list()
        if not kw_dict:
            kw_hash = ["default"]
        else:
            [kw_hash.append("{}-{}".format(key, h)) for (key, h) in sorted(kw_dict.items())]
        # hash closure vars - for case where filter_fn is defined within closure of filter_fn
        closure = []
        nonlocals = inspect.getclosurevars(filter_fn).nonlocals
        for (key, val) in nonlocals.items():
            ## capture hash for any function within closure
            if inspect.isfunction(val):
                closure.append(self._hash_filter_fn(val))
        closure.sort() # Sorted for file name consistency
        closure_str = "null" if len(closure) == 0 else "-".join(closure)
        # construct final string comprising hashed components
        hashed_fn = ".".join(["-".join([filter_fn_name,
                                        str(hashed_fn_source)]),
                              ".".join(kw_hash),
                              closure_str]
                            )
        return hashed_fn
529335
def linter_functions_from_filters(whitelist=None,
                                  blacklist=None):
    """"""
    def _keyvalue_pair_if(dictionary, condition):
        """Return a key-value pair in dictionary if condition matched."""
        return {
            k: v for (k, v) in dictionary.items() if condition(k)
        }

    def _check_list(check_list, cond):
        """Return function testing against a list if the list exists."""
        def _check_against_list(key):
            """Return true if list exists and condition passes."""
            return cond(check_list, key) if check_list is not None else True

        return _check_against_list

    linter_functions = LINTER_FUNCTIONS
    linter_functions = _keyvalue_pair_if(linter_functions,
                                         _check_list(whitelist,
                                                     lambda l, k: k in l))
    linter_functions = _keyvalue_pair_if(linter_functions,
                                         _check_list(blacklist,
                                                     lambda l, k: k not in l))

    for code, linter_function in linter_functions.items():
        yield (code, linter_function)
436205
function parseFilter(filterString) {

    var ret = Color$1.convertMatches(filterString);
    var matches = ret.str.match(filter_regexp);

    if (!matches[0]) {
        return [];
    }

    var arr = matches[0].split('(');

    var filterName = arr.shift();
    var filterParams = [];

    if (arr.length) {
        filterParams = arr.shift().split(')')[0].split(',').map(function (f) {
            return Color$1.reverseMatches(f, ret.matches);
        });
    }

    var result = [filterName].concat(toConsumableArray(filterParams)).map(Color$1.trim);

    return result;
}
325149
function(filterFunc) {
    filterFunc = filterFunc || goog.functions.TRUE;
    return function(root, ret, bag) {
      var te, x = 0, tret = root[childNodesName];
      while (te = tret[x++]) {
        if (
          simpleNodeTest(te) &&
          (!bag || _isUnique(te, bag)) &&
          (filterFunc(te, x))
        ) {
          ret.push(te);
        }
      }
      return ret;
    };
  }
370532
function(fn) {
    var views;

    // If the filter argument is a String, then return a chained Version of the
    // elements. The value at the specified filter may be undefined, a single
    // view, or an array of views; in all cases, chain on a flat array.
    if (typeof fn === "string") {
      fn = this.sections[fn] || fn;
      views = this.views[fn] || [];

      // If Views is undefined you are concatenating an `undefined` to an array
      // resulting in a value being returned.  Defaulting to an array prevents
      // this.
      //return _.chain([].concat(views || []));
      return _.chain([].concat(views));
    }

    // Generate an array of all top level (no deeply nested) Views flattened.
    views = _.chain(this.views).map(function(view) {
      return _.isArray(view) ? view : [view];
    }, this).flatten();

    // If the argument passed is an Object, then pass it to `_.where`.
    if (typeof fn === "object") {
      return views.where(fn);
    }

    // If a filter function is provided, run it on all Views and return a
    // wrapped chain. Otherwise, simply return a wrapped chain of all Views.
    return typeof fn === "function" ? views.filter(fn) : views;
  }
258334
function makeRecencyFilter(timeFn) {
  var lastTime = 0;

  return function(items) {
    var out = [];
    items.forEach(function(item) {
      if (timeFn(item) > lastTime) {
        out.push(item);
      }
    });
    out.forEach(function(item) {
      lastTime = Math.max(lastTime, timeFn(item));
    });

    return out;
  };
}
1132247
function (filter) {
    var obj = {}
    var val = this.__input

    this.each(function (property, key) {
      obj[key] = property.flatten ? property.flatten(filter) : property
    }, wrapFilter(filter))

    if (val !== void 0) {
      if (val instanceof Base) {
        val = {
          reference: val.path
        }
      }
      obj.val = val
    }

    // refactoring non standard keys
    var flattened = flatten(obj)
    for (var key in flattened) {
      if (key.indexOf('.val') > 0) {
        var newKey = key.split('.val')[0]
        flattened[newKey] = flattened[key]
        delete flattened[key]
      }
    }
    return flattened
  }
418993
def filter_protected(f):
    
    def new_f(self, *args, **kwargs):
        for obj in f(self, *args, **kwargs):
            if self.protected == False:
                if 'user' in obj and obj['user']['protected']:
                    continue
                elif 'protected' in obj and obj['protected']:
                    continue
            yield obj

    return new_f
1096704
def _mk_cache_fn(vcf_fn, array_type, region=None, cachedir=None,
                 compress=False):
    """"""

    # ensure cache dir exists
    if cachedir is None:
        # use the VCF file name as the base for a directory name
        cachedir = vcf_fn + config.CACHEDIR_SUFFIX
    if not os.path.exists(cachedir):
        # ensure cache dir exists
        os.makedirs(cachedir)
    else:
        assert os.path.isdir(cachedir), \
            'unexpected error, cache directory is not a directory: %r' \
            % cachedir

    # handle compression
    if compress:
        suffix = 'npz'
    else:
        suffix = 'npy'

    # handle region
    if region is None:
        # loading the whole genome (i.e., all variants)
        cache_fn = os.path.join(cachedir, '%s.%s' % (array_type, suffix))
    else:
        # loading a specific region
        region = region.replace(':', '__').replace('-', '_')
        cache_fn = os.path.join(cachedir, '%s.%s.%s' % (array_type, region,
                                                        suffix))
    return cache_fn
714016
function(arr,filterFunc) {
	
	if (arr.filter) { return arr.filter(filterFunc); }
	
	var i = 0,
		l = 0,
		r = [];
	
	for (i = 0, l = arr.length; i < l; i++) {
		if (filterFunc(arr[i])) {
			r.push(arr[i]);
		}
	}
	
	return r;
}
601270
def _fn_matches(fn, glob):
    """"""
    if glob not in _pattern_cache:
        pattern = _pattern_cache[glob] = re.compile(fnmatch.translate(glob))
        return pattern.match(fn)
    return _pattern_cache[glob].match(fn)
338967
function (filters, tpl) {
      for (var i = 0; i < filters.length; ++i) {
        tpl = filters[i](tpl)
      }
      return tpl
    }
729161
def condition_filterrific_params(fp)
      fp.each do |key, val|
        case
        when val.is_a?(Proc)
          # evaluate Procs
          fp[key] = val.call
        when val.is_a?(Array)
          # type cast integers in the array
          fp[key] = fp[key].map { |e| e =~ integer_detector_regex ? e.to_i : e }
        when val.is_a?(Hash)
          # type cast Hash to OpenStruct so that nested params render correctly
          # in the form
          fp[key] = OpenStruct.new(fp[key])
        when val =~ integer_detector_regex
          # type cast integer
          fp[key] = fp[key].to_i
        end
      end
      fp
    end
148702
def cached(f):
    
    @functools.wraps(f)
    def wrapped(*args, **kwargs):
        with _cache_lock:
            identifier = (f.__name__,  args, kwargs)
            key = pickle.dumps(identifier)
            value = cache.get(key)
            if value is not None:
                logger.debug("HIT for %s -> %s" % (str(identifier), value))
            else:
                logger.debug("MISS for %s" % str(identifier))
                value = f(*args, **kwargs)
                cache[key] = value
            return value
    return wrapped
720303
function parseFilterTypes(filters)
  {
    if(typeof filters === 'string') filters = getfilters(filters);
    
    var filterObj = {
          filters:[],
          vmFilters:[],
          model:[],
          local:[],
          session:[]
        },
        x = 0,
        len = filters.length,
        filter;
    
    for(x;x<len;x++)
    {
      filter = filters[x];
      
      if(filter.match(__matchVFilters))
      {
        filterObj.vmFilters.push(filter.replace(__replaceVFilters, ''));
      }
      else if(filter.match(__matchStoreFilter))
      {
        if(filter.indexOf('~') !== -1) filterObj.model.push(filter.replace(__replaceStoreFilter, ''));
        if(filter.indexOf('+') !== -1) filterObj.local.push(filter.replace(__replaceStoreFilter, ''));
        if(filter.indexOf('-') !== -1) filterObj.session.push(filter.replace(__replaceStoreFilter, ''));
      }
      else
      {
        filterObj.filters.push(filter);
      }
    }
    
    return filterObj;
  }
397304
def filter_t(func):
    
    return Transformation('filter({0})'.format(name(func)),
                          partial(filter, func),
                          {ExecutionStrategies.PARALLEL})
800482
function _fnBefore(options, node) {
                if (options.filter.length === 0) {
                    return true;
                } else {
                    return _fnProccess(node, options.filter, options.beginAnd || false);
                }
            }