Skip to content

Commit

Permalink
FIX-modin-project#7088: make sure 'rank' raises 'No axis named None..…
Browse files Browse the repository at this point in the history
….' exception

Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
  • Loading branch information
anmyachev committed Mar 13, 2024
1 parent 909afdd commit 9b85f5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2362,6 +2362,10 @@ def rank(
ascending: bool = True,
pct: bool = False,
):
if axis is None:
raise ValueError(
f"No axis named None for object type {type(self).__name__}"
)
axis = self._get_axis_number(axis)
return self.__constructor__(
query_compiler=self._query_compiler.rank(
Expand Down
6 changes: 5 additions & 1 deletion modin/pandas/test/dataframe/test_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,20 @@ def test_sum_single_column(data):


@pytest.mark.parametrize(
"fn", ["max", "min", "median", "mean", "skew", "kurt", "sem", "std", "var"]
"fn", ["max", "min", "median", "mean", "skew", "kurt", "sem", "std", "var", "rank"]
)
@pytest.mark.parametrize("axis", [0, 1, None])
@pytest.mark.parametrize(
"numeric_only", bool_arg_values, ids=arg_keys("numeric_only", bool_arg_keys)
)
def test_reduce_specific(fn, numeric_only, axis):
raising_exceptions = None
if numeric_only and axis is None and fn == "rank":
raising_exceptions = ValueError("No axis named None for object type DataFrame")
eval_general(
*create_test_dfs(test_data_diff_dtype),
lambda df: getattr(df, fn)(numeric_only=numeric_only, axis=axis),
raising_exceptions=raising_exceptions,
)


Expand Down

0 comments on commit 9b85f5b

Please sign in to comment.