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 6e0c37e commit 778be02
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
6 changes: 5 additions & 1 deletion modin/core/dataframe/base/dataframe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import pandas
from pandas._typing import IndexLabel
from pandas.api.types import is_scalar
from pandas.core.dtypes.common import is_float_dtype, is_numeric_dtype


class Axis(Enum): # noqa: PR01
Expand Down Expand Up @@ -169,7 +170,10 @@ def is_trivial_index(index: pandas.Index) -> bool:
return True
if isinstance(index, pandas.RangeIndex):
return index.start == 0 and index.step == 1
if not (isinstance(index, pandas.Index) and index.dtype == "int64"):
if not (
isinstance(index, pandas.Index)
and (is_numeric_dtype(index) and not is_float_dtype(index))
):
return False
return (
index.is_monotonic_increasing
Expand Down
4 changes: 3 additions & 1 deletion modin/tests/pandas/dataframe/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ def test_pivot_table_data(data, index, columns, values, aggfunc, request):
[pytest.param("Custom name", id="str_name")],
)
@pytest.mark.parametrize("fill_value", [None, 0])
@pytest.mark.parametrize("backend", [None, "pyarrow"])
def test_pivot_table_margins(
data,
index,
Expand All @@ -786,13 +787,14 @@ def test_pivot_table_margins(
aggfunc,
margins_name,
fill_value,
backend,
request,
):
expected_exception = None
if "dict_func" in request.node.callspec.id:
expected_exception = KeyError("Column(s) ['col28', 'col38'] do not exist")
eval_general(
*create_test_dfs(data),
*create_test_dfs(data, backend=backend),
operation=lambda df, *args, **kwargs: df.pivot_table(*args, **kwargs),
index=index,
columns=columns,
Expand Down
10 changes: 3 additions & 7 deletions modin/tests/pandas/dataframe/test_map_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1429,9 +1429,6 @@ def comparator(df1, df2):
elif idx == 2:
# FIXME: https://github.com/modin-project/modin/issues/7080
expected_exception = False

if any("pyarrow" in str(dtype) for dtype in pandas_df.dtypes):
pytest.xfail(reason="ValueError(2)")
eval_insert(
modin_df,
pandas_df,
Expand Down Expand Up @@ -1686,13 +1683,12 @@ def test___neg__(request, data):
@pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
def test___invert__(data, request):
expected_exception = None
md_df, pd_df = create_test_dfs(data)
if "float_nan_data" in request.node.callspec.id:
# FIXME: https://github.com/modin-project/modin/issues/7081
expected_exception = False
if any("pyarrow" in str(dtype) for dtype in pd_df.dtypes):
pytest.xfail(reason="pyarrow.lib.ArrowNotImplementedError")
eval_general(md_df, pd_df, lambda df: ~df, expected_exception=expected_exception)
eval_general(
*create_test_dfs(data), lambda df: ~df, expected_exception=expected_exception
)


def test___invert___bool():
Expand Down
3 changes: 1 addition & 2 deletions modin/tests/pandas/dataframe/test_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,9 @@ def test_sum(data, axis, skipna, is_transposed, request):
df_equals(modin_result, pandas_result)


@pytest.mark.parametrize("dtype", ["int64", "Int64"])
@pytest.mark.parametrize("dtype", ["int64", "Int64", "int64[pyarrow]"])
def test_dtype_consistency(dtype):
# test for issue #6781
# TODO: add pyarrow dtype
res_dtype = pd.DataFrame([1, 2, 3, 4], dtype=dtype).sum().dtype
assert res_dtype == pandas.api.types.pandas_dtype(dtype)

Expand Down

0 comments on commit 778be02

Please sign in to comment.