Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
  • Loading branch information
anmyachev committed Apr 23, 2024
1 parent 65c056c commit fb0ea59
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
26 changes: 4 additions & 22 deletions tests/column/shift_test.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,25 @@
import pandas as pd
import polars as pl
import pytest
from polars.testing import assert_frame_equal

from tests.utils import BaseHandler
from tests.utils import compare_dataframe_with_reference
from tests.utils import float_dataframe_1
from tests.utils import integer_dataframe_1


def test_shift_with_fill_value(library: BaseHandler) -> None:
if library.name == "modin":
pytest.skip("TODO: enable for modin")
df = integer_dataframe_1(library)
ns = df.__dataframe_namespace__()
result = df.assign(df.col("a").shift(1).fill_null(999))
if library.name == "pandas-numpy":
if library.name in ("pandas-numpy", "modin"):
result = result.cast({name: ns.Int64() for name in ("a", "b")})
expected = {"a": [999, 1, 2], "b": [4, 5, 6]}
compare_dataframe_with_reference(result, expected, dtype=ns.Int64)


def test_shift_without_fill_value(library: BaseHandler) -> None:
if library.name == "modin":
pytest.skip("TODO: enable for modin")
df = float_dataframe_1(library)
ns = df.__dataframe_namespace__()
result = df.assign(df.col("a").shift(-1))
if library.name == "pandas-numpy":
expected = pd.DataFrame({"a": [3.0, float("nan")]})
pd.testing.assert_frame_equal(result.dataframe, expected)
elif library.name == "pandas-nullable":
expected = pd.DataFrame({"a": [3.0, None]}, dtype="Float64")
pd.testing.assert_frame_equal(result.dataframe, expected)
elif library.name == "polars-lazy":
expected = pl.DataFrame({"a": [3.0, None]})
assert_frame_equal(result.dataframe.collect(), expected) # type: ignore[attr-defined]
else: # pragma: no cover
msg = "unexpected library"
raise AssertionError(msg)
expected = {"a": [3.0, float("nan")]}
compare_dataframe_with_reference(result, expected, dtype=ns.Float64)


def test_shift_with_fill_value_complicated(library: BaseHandler) -> None:
Expand Down
16 changes: 16 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import sys
from typing import Any

import pytest

from tests.utils import ModinHandler
from tests.utils import PandasHandler
from tests.utils import PolarsHandler
Expand Down Expand Up @@ -56,3 +58,17 @@ def pytest_generate_tests(metafunc: Any) -> None:
lib_handlers = [LIBRARIES_HANDLERS[lib] for lib in libraries]

metafunc.parametrize("library", lib_handlers, ids=libraries)


ci_xfail_ids = [
# https://github.com/modin-project/modin/issues/7212
"join_test.py::test_join_left[modin]",
"join_test.py::test_join_two_keys[modin]",
"persistedness_test.py::test_cross_df_propagation[modin]",
]


def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
for item in items:
if any(id_ in item.nodeid for id_ in ci_xfail_ids):
item.add_marker(pytest.mark.xfail(strict=True))
4 changes: 0 additions & 4 deletions tests/dataframe/join_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@


def test_join_left(library: BaseHandler) -> None:
if library.name == "modin":
pytest.skip("TODO: enable for modin")
left = integer_dataframe_1(library)
right = integer_dataframe_2(library).rename({"b": "c"})
result = left.join(right, left_on="a", right_on="a", how="left")
Expand Down Expand Up @@ -73,8 +71,6 @@ def test_join_outer(library: BaseHandler) -> None: # pragma: no cover


def test_join_two_keys(library: BaseHandler) -> None:
if library.name == "modin":
pytest.skip("TODO: enable for modin")
left = integer_dataframe_1(library)
right = integer_dataframe_2(library).rename({"b": "c"})
result = left.join(right, left_on=["a", "b"], right_on=["a", "c"], how="left")
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/persistedness_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ def test_within_df_within_col_propagation(library: BaseHandler) -> None:


def test_cross_df_propagation(library: BaseHandler) -> None:
if library.name == "modin":
pytest.skip("TODO: enable for modin")
df1 = integer_dataframe_1(library)
df2 = integer_dataframe_2(library)
ns = df1.__dataframe_namespace__()
Expand Down

0 comments on commit fb0ea59

Please sign in to comment.