Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev committed May 13, 2024
1 parent 9d6d839 commit 5de824e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ def prod(
and numeric_only is False
and min_count > len(axis_to_apply)
# Type inference is not so simple for pyarrow
and self._query_compiler.get_backend() is not None
and self._query_compiler.get_backend() is None
):
new_index = self.columns if not axis else self.index
# >>> pd.DataFrame([1,2,3,4], dtype="int64[pyarrow]").prod(min_count=10)
Expand Down Expand Up @@ -2153,7 +2153,7 @@ def sum(
and numeric_only is False
and min_count > len(axis_to_apply)
# Type inference is not so simple for pyarrow
and self._query_compiler.get_backend() is not None
and self._query_compiler.get_backend() is None
):
new_index = self.columns if not axis else self.index
return Series(
Expand Down
19 changes: 8 additions & 11 deletions modin/tests/pandas/dataframe/test_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
*("truediv", "rtruediv", "mul", "rmul", "floordiv", "rfloordiv"),
],
)
def test_math_functions(other, axis, op):
@pytest.mark.parametrize("backend", [None, "pyarrow"])
def test_math_functions(other, axis, op, backend):
data = test_data["float_nan_data"]
if (op == "floordiv" or op == "rfloordiv") and axis == "rows":
# lambda == "series_or_list"
Expand All @@ -85,16 +86,12 @@ def test_math_functions(other, axis, op):
# lambda == "series_or_list"
pytest.xfail(reason="different behavior")

md_df, pd_df = create_test_dfs(data)
if op in ("mod", "rmod") and any("pyarrow" in str(dtype) for dtype in pd_df.dtypes):
with pytest.raises(NotImplementedError):
eval_general(
md_df, pd_df, lambda df: getattr(df, op)(other(df, axis), axis=axis)
)
else:
eval_general(
md_df, pd_df, lambda df: getattr(df, op)(other(df, axis), axis=axis)
)
if op in ("mod", "rmod") and backend == "pyarrow":
pytest.skip(reason="Not implemented for pyarrow backend")
eval_general(
*create_test_dfs(data, backend="pyarrow"),
lambda df: getattr(df, op)(other(df, axis), axis=axis),
)


@pytest.mark.parametrize("other", [lambda df: 2, lambda df: df])
Expand Down
6 changes: 6 additions & 0 deletions modin/tests/pandas/dataframe/test_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ def test_sum_prod_specific(fn, min_count, numeric_only):
)


@pytest.mark.parametrize("backend", [None, "pyarrow"])
def test_sum_prod_min_count(backend):
md_df, pd_df = create_test_dfs(test_data["float_nan_data"], backend=backend)
eval_general(md_df, pd_df, lambda df: df.prod(min_count=len(pd_df) + 1))


@pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
def test_sum_single_column(data):
modin_df = pd.DataFrame(data).iloc[:, [0]]
Expand Down

0 comments on commit 5de824e

Please sign in to comment.