pipes.py 文件源码

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

项目:pydatapipes 作者: janschulz 项目源码 文件源码
def singledispatch_pipeverb(func):
    """
    Convenience decorator to convert a function to a singledispatch pipeline verb

    The function is converted to a :func:`singledispatch` function and then
    converted into an instance of class :class:`PipeVerb` via :func:`pipeverb`.

    This decorator is equivalent to ``verb = pipeverb(singledispatch(func))``

    Please see :func:`pipeverb` for rules which a pipeline verb has to follow!

    :param func: the function which should be converted
    :type func: function
    :return: PipeVerb instance which can be used in rshift `>>` operations
    :rtype: PipeVerb

    :Example:

    >>> @singledispatch_pipeverb
    >>> def my_verb_impl(input, x=1, y=2):
    >>>     raise NotImplementedError("my_verb is not implemented for data of type %s" % type(input))
    >>> @my_verb_impl.register(pd.DataFrame)
    >>> def my_verb_impl_df(input, x=1, y=2):
    >>>     # do something with input being a Dataframe
    >>>     pass
    >>> # ensure that pd.DataFrame is useable as a pipe source
    >>> make_pipesource(pd.DataFrame)


    .. seealso:: :func:`pipeverb`, :func:`singledispatch`
    """
    return pipeverb(singledispatch(func))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号