mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-30 05:07:29 +08:00
ENH: Include sharedoc function
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from zipline.testing import ZiplineTestCase
|
||||
from zipline.utils.sharedoc import copydoc
|
||||
|
||||
|
||||
class TestSharedoc(ZiplineTestCase):
|
||||
|
||||
def test_copydoc(self):
|
||||
def original_docstring_function():
|
||||
"""
|
||||
My docstring brings the boys to the yard.
|
||||
"""
|
||||
pass
|
||||
|
||||
@copydoc(original_docstring_function)
|
||||
def copied_docstring_function():
|
||||
pass
|
||||
|
||||
self.assertEqual(
|
||||
original_docstring_function.__doc__,
|
||||
copied_docstring_function.__doc__
|
||||
)
|
||||
@@ -12,7 +12,6 @@ from six import (
|
||||
with_metaclass,
|
||||
)
|
||||
from numpy import array
|
||||
from odo.utils import copydoc
|
||||
from pandas import DataFrame, MultiIndex
|
||||
from toolz import groupby, juxt
|
||||
from toolz.curried.operator import getitem
|
||||
@@ -30,6 +29,7 @@ from .term import AssetExists, InputDates, LoadableTerm
|
||||
|
||||
from zipline.utils.date_utils import compute_date_range_chunks
|
||||
from zipline.utils.pandas_utils import categorical_df_concat
|
||||
from zipline.utils.sharedoc import copydoc
|
||||
|
||||
|
||||
class PipelineEngine(with_metaclass(ABCMeta)):
|
||||
|
||||
@@ -5,6 +5,7 @@ across different functions.
|
||||
import re
|
||||
from six import iteritems
|
||||
from textwrap import dedent
|
||||
from toolz import curry
|
||||
|
||||
PIPELINE_DOWNSAMPLING_FREQUENCY_DOC = dedent(
|
||||
"""\
|
||||
@@ -98,3 +99,21 @@ def templated_docstring(**docs):
|
||||
f.__doc__ = format_docstring(f.__name__, f.__doc__, docs)
|
||||
return f
|
||||
return decorator
|
||||
|
||||
|
||||
@curry
|
||||
def copydoc(from_, to):
|
||||
"""Copies the docstring from one function to another.
|
||||
Parameters
|
||||
----------
|
||||
from_ : any
|
||||
The object to copy the docstring from.
|
||||
to : any
|
||||
The object to copy the docstring to.
|
||||
Returns
|
||||
-------
|
||||
to : any
|
||||
``to`` with the docstring from ``from_``
|
||||
"""
|
||||
to.__doc__ = from_.__doc__
|
||||
return to
|
||||
|
||||
Reference in New Issue
Block a user