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))
评论列表
文章目录