• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python toolz.filter函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中toolz.filter函数的典型用法代码示例。如果您正苦于以下问题:Python filter函数的具体用法?Python filter怎么用?Python filter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了filter函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: clear_cache

def clear_cache(scope=None):
    """
    Clear all cached data.

    Parameters
    ----------
    scope : {None, 'step', 'iteration', 'forever'}, optional
        Clear cached values with a given scope.
        By default all cached values are removed.

    """
    if not scope:
        _TABLE_CACHE.clear()
        _COLUMN_CACHE.clear()
        _INJECTABLE_CACHE.clear()
        for m in _MEMOIZED.values():
            m.value.clear_cached()
        logger.debug('simulation cache cleared')
    else:
        for d in (_TABLE_CACHE, _COLUMN_CACHE, _INJECTABLE_CACHE):
            items = toolz.valfilter(lambda x: x.scope == scope, d)
            for k in items:
                del d[k]
        for m in toolz.filter(lambda x: x.scope == scope, _MEMOIZED.values()):
            m.value.clear_cached()
        logger.debug('cleared cached values with scope {!r}'.format(scope))
开发者ID:advancedpartnerships,项目名称:urbansim,代码行数:26,代码来源:simulation.py


示例2: entrypoint

def entrypoint(dockerfile):
    "Return the entrypoint, if declared"
    f = dockerfile.split("\n")[::-1]  # reverse the lines
    try:
        entry_line = first(filter(lambda x: "ENTRYPOINT" in x, f))
    except StopIteration as e:
        # No ENTRYPOINT line was found
        return None
    else:
        res = last(entry_line.partition("ENTRYPOINT")).strip()
        try:
            return json.loads(res)
        except:
            return res.split()
        return None
开发者ID:ntdef,项目名称:hume,代码行数:15,代码来源:hume.py


示例3: compute_up

def compute_up(t, seq, **kwargs):
    predicate = optimize(t.predicate, seq)
    predicate = rrowfunc(predicate, child(t))
    return filter(predicate, seq)
开发者ID:jcrist,项目名称:blaze,代码行数:4,代码来源:python.py


示例4: all_block

 def all_block(self) -> List[Block]:
   return t.filter(lambda x: isinstance(x, Block), self.values())
开发者ID:vshesh,项目名称:glue,代码行数:2,代码来源:registry.py


示例5: all_inline

 def all_inline(self) -> List[Inline]:
   return t.filter(lambda x: isinstance(x, Inline), self.values())
开发者ID:vshesh,项目名称:glue,代码行数:2,代码来源:registry.py


示例6: compute_up

def compute_up(t, seq, **kwargs):
    predicate = rrowfunc(t.predicate, t._child)
    return filter(predicate, seq)
开发者ID:Casolt,项目名称:blaze,代码行数:3,代码来源:python.py


示例7: filter_stopwords

def filter_stopwords(tokenset):
    """
    Filters out stopwords.
    """
    return tlz.filter(lambda tkn: tkn not in STOPWORDS, tokenset)
开发者ID:steven-cutting,项目名称:SimpleTokenizer,代码行数:5,代码来源:utils.py


示例8: filter_longer_than

def filter_longer_than(n, tokenset):
    """
    Filters out tokens that have 'n' characters or more.
    """
    return tlz.filter(lambda tkn: len(tkn) < n, tokenset)
开发者ID:steven-cutting,项目名称:SimpleTokenizer,代码行数:5,代码来源:utils.py


示例9: filter_stopwords

def filter_stopwords(tokenset):
    """
    Filters out tokens that are stopwords.
    """
    return tlz.filter(not_stopword, tokenset)
开发者ID:steven-cutting,项目名称:text2math,代码行数:5,代码来源:text2tokens.py


示例10: filter_whitespace

def filter_whitespace(tokenset):
    """
    Filters out tokens that are only whitespace.
    """
    return tlz.filter(tlz.compose(bool, str.strip), tokenset)
开发者ID:steven-cutting,项目名称:SimpleTokenizer,代码行数:5,代码来源:utils.py


示例11: compute_up

def compute_up(expr, seq, predicate, **kwargs):
    preds = iter(predicate)
    return filter(lambda _: next(preds), seq)
开发者ID:blaze,项目名称:blaze,代码行数:3,代码来源:python.py


示例12: sorted

    
deps.number_of_edges()
deps.number_of_nodes()
deps.node['skimage']
deps.in_edges('skimage')
nodes = nx.katz_centrality(deps)
central = sorted(deps.nodes(), key=nodes.__getitem__, reverse=True)
central[:10]
central[:20]
central[:40]
central[40:80]
central.index('skimage')
central.index('scipy')
import pickle
stdlib = pickle.load(open('/Users/jni/projects/depsy/data/python_standard_libs.pickle', 'rb'))
central_nonstd = list(tz.filter(lambda x: x not in stdlib, central))
len(central_nonstd)
central_nonstd.index('scipy')
len(central)
central[:5]
nx.is_connected(deps.to_undirected())
len(packages)
deps_sym = deps.to_undirected()
import numpy as np
conncomps = list(nx.connected_component_subgraphs(deps_sym))
giant = conncomps[0]
giant_d = deps.subgraph(giant.nodes())
gpackages = giant_d.nodes()
A = nx.to_scipy_sparse_matrix(giant_d)
A.shape
A.dtype
开发者ID:jni,项目名称:useful-histories,代码行数:30,代码来源:read-python-dependency-graph.py


示例13: sfilter

def sfilter(pred, fn, x):
    """ Yield only those results which satisfy the predicate """
    for x in filter(pred, fn(x)):
        yield x
开发者ID:mrocklin,项目名称:strategies,代码行数:4,代码来源:core.py


示例14: compute_up_1d

def compute_up_1d(t, seq, **kwargs):
    return toolz.count(filter(None, seq))
开发者ID:jcrist,项目名称:blaze,代码行数:2,代码来源:python.py


示例15: filter_shorter_than

def filter_shorter_than(n, tokenset):
    """
    Filters out tokens that have less than 'n' characters.
    """
    return tlz.filter(lambda tkn: len(tkn) >= n, tokenset)
开发者ID:steven-cutting,项目名称:SimpleTokenizer,代码行数:5,代码来源:utils.py


示例16: filter_whitespace

def filter_whitespace(tokenset):
    """
    Filters out tokens that are only whitespace.
    """
    return tlz.filter(tlz.compose(bool, lambda string: string.strip()), tokenset)
开发者ID:steven-cutting,项目名称:text2math,代码行数:5,代码来源:text2tokens.py



注:本文中的toolz.filter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python toolz.first函数代码示例发布时间:2022-05-27
下一篇:
Python toolz.curry函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap