Skip to content

Commit

Permalink
REFACTOR-modin-project#7017: Align 'to_hdf' and 'hist' signatures to …
Browse files Browse the repository at this point in the history
…pandas (modin-project#7018)

Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
  • Loading branch information
anmyachev committed Mar 6, 2024
1 parent 47a886c commit a64e5d1
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 32 deletions.
36 changes: 32 additions & 4 deletions modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import pickle as pkl
import re
import warnings
from typing import Any, Hashable, Optional, Sequence, Union
from typing import Any, Hashable, Literal, Optional, Sequence, Union

import numpy as np
import pandas
Expand Down Expand Up @@ -3236,13 +3236,41 @@ def to_dict(self, orient="dict", into=dict, index=True):

@expanduser_path_arg("path_or_buf")
def to_hdf(
self, path_or_buf, key, format="table", **kwargs
): # pragma: no cover # noqa: PR01, RT01, D200
self,
path_or_buf,
key: str,
mode: Literal["a", "w", "r+"] = "a",
complevel: int | None = None,
complib: Literal["zlib", "lzo", "bzip2", "blosc"] | None = None,
append: bool = False,
format: Literal["fixed", "table"] | None = None,
index: bool = True,
min_itemsize: int | dict[str, int] | None = None,
nan_rep=None,
dropna: bool | None = None,
data_columns: Literal[True] | list[str] | None = None,
errors: str = "strict",
encoding: str = "UTF-8",
) -> None: # pragma: no cover # noqa: PR01, RT01, D200
"""
Write the contained data to an HDF5 file using HDFStore.
"""
return self._default_to_pandas(
"to_hdf", path_or_buf, key, format=format, **kwargs
"to_hdf",
path_or_buf,
key=key,
mode=mode,
complevel=complevel,
complib=complib,
append=append,
format=format,
index=index,
min_itemsize=min_itemsize,
nan_rep=nan_rep,
dropna=dropna,
data_columns=data_columns,
errors=errors,
encoding=encoding,
)

@expanduser_path_arg("path_or_buf")
Expand Down
42 changes: 26 additions & 16 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@
import numpy as np
import pandas
from pandas._libs import lib
from pandas._typing import CompressionOptions, FilePath, StorageOptions, WriteBuffer
from pandas._typing import (
CompressionOptions,
FilePath,
IndexLabel,
StorageOptions,
WriteBuffer,
)
from pandas.core.common import apply_if_callable, get_cython_func
from pandas.core.computation.eval import _check_engine
from pandas.core.dtypes.common import (
Expand Down Expand Up @@ -966,26 +972,28 @@ def gt(self, other, axis="columns", level=None): # noqa: PR01, RT01, D200
)

def hist(
self,
column=None,
data,
column: IndexLabel | None = None,
by=None,
grid=True,
xlabelsize=None,
xrot=None,
ylabelsize=None,
yrot=None,
grid: bool = True,
xlabelsize: int | None = None,
xrot: float | None = None,
ylabelsize: int | None = None,
yrot: float | None = None,
ax=None,
sharex=False,
sharey=False,
figsize=None,
layout=None,
bins=10,
**kwds,
sharex: bool = False,
sharey: bool = False,
figsize: tuple[int, int] | None = None,
layout: tuple[int, int] | None = None,
bins: int | Sequence[int] = 10,
backend: str | None = None,
legend: bool = False,
**kwargs,
): # pragma: no cover # noqa: PR01, RT01, D200
"""
Make a histogram of the ``DataFrame``.
"""
return self._default_to_pandas(
return data._default_to_pandas(
pandas.DataFrame.hist,
column=column,
by=by,
Expand All @@ -1000,7 +1008,9 @@ def hist(
figsize=figsize,
layout=layout,
bins=bins,
**kwds,
backend=backend,
legend=legend,
**kwargs,
)

def info(
Expand Down
24 changes: 14 additions & 10 deletions modin/pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numpy as np
import pandas
from pandas._libs import lib
from pandas._typing import Axis, IndexKeyFunc
from pandas._typing import Axis, IndexKeyFunc, Sequence
from pandas.api.types import is_integer
from pandas.core.common import apply_if_callable, is_bool_indexer
from pandas.core.dtypes.common import is_dict_like, is_list_like
Expand Down Expand Up @@ -1123,14 +1123,16 @@ def hist(
self,
by=None,
ax=None,
grid=True,
xlabelsize=None,
xrot=None,
ylabelsize=None,
yrot=None,
figsize=None,
bins=10,
**kwds,
grid: bool = True,
xlabelsize: int | None = None,
xrot: float | None = None,
ylabelsize: int | None = None,
yrot: float | None = None,
figsize: tuple[int, int] | None = None,
bins: int | Sequence[int] = 10,
backend: str | None = None,
legend: bool = False,
**kwargs,
): # noqa: PR01, RT01, D200
"""
Draw histogram of the input series using matplotlib.
Expand All @@ -1146,7 +1148,9 @@ def hist(
yrot=yrot,
figsize=figsize,
bins=bins,
**kwds,
backend=backend,
legend=legend,
**kwargs,
)

def idxmax(self, axis=0, skipna=True, *args, **kwargs): # noqa: PR01, RT01, D200
Expand Down
4 changes: 2 additions & 2 deletions modin/pandas/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_dataframe_api_equality():
), "Differences found in API: {}".format(set(modin_dir) - set(pandas_dir))

# These have to be checked manually
allowed_different = ["to_hdf", "hist", "modin"]
allowed_different = ["modin"]

assert_parameters_eq((pandas.DataFrame, pd.DataFrame), modin_dir, allowed_different)

Expand Down Expand Up @@ -275,7 +275,7 @@ def test_series_api_equality():
)

# These have to be checked manually
allowed_different = ["to_hdf", "hist", "modin"]
allowed_different = ["modin"]

assert_parameters_eq((pandas.Series, pd.Series), modin_dir, allowed_different)

Expand Down

0 comments on commit a64e5d1

Please sign in to comment.