Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/ray/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
from .iterator import PartitionIterator


@_inherit_docstrings(pd.DataFrame)
@_inherit_docstrings(pd.DataFrame,
excluded=[pd.DataFrame, pd.DataFrame.__init__])
class DataFrame(object):

def __init__(self, data=None, index=None, columns=None, dtype=None,
Expand Down
4 changes: 3 additions & 1 deletion python/ray/dataframe/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
from .utils import _inherit_docstrings


@_inherit_docstrings(pandas.core.groupby.DataFrameGroupBy)
@_inherit_docstrings(pandas.core.groupby.DataFrameGroupBy,
excluded=[pandas.core.groupby.DataFrameGroupBy,
pandas.core.groupby.DataFrameGroupBy.__init__])
class DataFrameGroupBy(object):

def __init__(self, df, by, axis, level, as_index, sort, group_keys,
Expand Down
2 changes: 1 addition & 1 deletion python/ray/dataframe/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def na_op():
raise NotImplementedError("Not Yet implemented.")


@_inherit_docstrings(pd.Series)
@_inherit_docstrings(pd.Series, excluded=[pd.Series, pd.Series.__init__])
class Series(object):

def __init__(self, series_oids):
Expand Down
23 changes: 9 additions & 14 deletions python/ray/dataframe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,34 +321,29 @@ def _blocks_to_row(*partition):
return row_part


def _inherit_docstrings(parent):
def _inherit_docstrings(parent, excluded=[]):
"""Creates a decorator which overwrites a decorated class' __doc__
attribute with parent's __doc__ attribute. Also overwrites __doc__ of
methods and properties defined in the class with the __doc__ of matching
methods in parent.
methods and properties in parent.

Args:
parent (object): Class from which the decorated class inherits __doc__.

Note:
Currently does not override class' __doc__ or __init__'s __doc__.

Todo:
Override the class' __doc__ and __init__'s __doc__ once DataFrame's
__init__ method matches pandas.DataFrame's __init__ method.
excluded (list): List of parent objects from which the class does not
inherit docstrings.

Returns:
function: decorator which replaces the decorated class' documentation
parent's documentation.
"""
def decorator(cls):
# cls.__doc__ = parent.__doc__
if parent not in excluded:
cls.__doc__ = parent.__doc__
for attr, obj in cls.__dict__.items():
if attr == "__init__":
continue
parent_obj = getattr(parent, attr, None)
if not callable(parent_obj) and \
not isinstance(parent_obj, property):
if parent_obj in excluded or \
(not callable(parent_obj) and
not isinstance(parent_obj, property)):
continue
if callable(obj):
obj.__doc__ = parent_obj.__doc__
Expand Down