preprocess.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:zipline-chinese 作者: zhanghan1990 项目源码 文件源码
def call(f):
    """
    Wrap a function in a processor that calls `f` on the argument before
    passing it along.

    Useful for creating simple arguments to the `@preprocess` decorator.

    Parameters
    ----------
    f : function
        Function accepting a single argument and returning a replacement.

    Usage
    -----
    >>> @preprocess(x=call(lambda x: x + 1))
    ... def foo(x):
    ...     return x
    ...
    >>> foo(1)
    2
    """
    @wraps(f)
    def processor(func, argname, arg):
        return f(arg)
    return processor
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号