Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX-#7134: Use a separate docstring class for BasePandasDataset. #7353

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
4 changes: 2 additions & 2 deletions modin/tests/config/docs_module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.

from .classes import DataFrame, Series
from .classes import BasePandasDataset, DataFrame, Series
from .functions import read_csv

__all__ = ["DataFrame", "Series", "read_csv"]
__all__ = ["BasePandasDataset", "DataFrame", "Series", "read_csv"]
8 changes: 8 additions & 0 deletions modin/tests/config/docs_module/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@
def isna(self):
"""This is a test of the documentation module for Series."""
return


class BasePandasDataset:
"""This is a test of the documentation module for BasePandasDataSet."""

def apply():
Dismissed Show dismissed Hide dismissed
"""This is a test of the documentation module for BasePandasDataSet.apply."""
return
8 changes: 8 additions & 0 deletions modin/tests/config/test_envvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import modin.pandas as pd
from modin.config.envvars import _check_vars
from modin.config.pubsub import _UNSET, ExactStr
from modin.pandas.base import BasePandasDataset


def reset_vars(*vars: tuple[cfg.Parameter]):
Expand Down Expand Up @@ -89,13 +90,20 @@ def test_overrides(self):
cfg.DocModule.put("modin.tests.config.docs_module")

# Test for override
assert BasePandasDataset.__doc__ == (
"This is a test of the documentation module for BasePandasDataSet."
)
assert BasePandasDataset.apply.__doc__ == (
"This is a test of the documentation module for BasePandasDataSet.apply."
)
assert (
pd.DataFrame.apply.__doc__
== "This is a test of the documentation module for DataFrame."
)
# Test for pandas doc when method is not defined on the plugin module
assert pandas.DataFrame.isna.__doc__ in pd.DataFrame.isna.__doc__
assert pandas.DataFrame.isnull.__doc__ in pd.DataFrame.isnull.__doc__
assert BasePandasDataset.astype.__doc__ in pd.DataFrame.astype.__doc__
# Test for override
assert (
pd.Series.isna.__doc__
Expand Down
13 changes: 12 additions & 1 deletion modin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,18 @@ def _inherit_docstrings_in_place(
if doc_module != DocModule.default and "pandas" in str(
getattr(parent, "__module__", "")
):
parent = getattr(imported_doc_module, getattr(parent, "__name__", ""), parent)
parent_name = (
# DocModule should use the class BasePandasDataset to override the
# docstrings of BasePandasDataset, even if BasePandasDataset
# normally inherits docstrings from a different `parent`.
"BasePandasDataset"
if getattr(cls_or_func, "__name__", "") == "BasePandasDataset"
# For other classes, override docstrings with the class that has the
# same name as the `parent` class, e.g. DataFrame inherits
# docstrings from doc_module.DataFrame.
else getattr(parent, "__name__", "")
)
parent = getattr(imported_doc_module, parent_name, parent)
if parent != default_parent:
# Reset API link in case the docs are overridden.
apilink = None
Expand Down
Loading