Skip to content

Commit 0b188ab

Browse files
committed
Assume unmerged spec behaviour
data-apis/dataframe-api#74
1 parent 3240e5a commit 0b188ab

File tree

4 files changed

+23
-30
lines changed

4 files changed

+23
-30
lines changed

tests/conftest.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
from typing import Union
23

34
import pytest
@@ -38,17 +39,15 @@ def pytest_configure(config):
3839

3940

4041
ci_failing_ids = [
41-
# dataframe objects return the interchange dataframe, not a dict, although
42-
# this is the behaviour that should be in the spec soon.
43-
# See https://github.com/data-apis/dataframe-api/pull/74
44-
"test_dataframe_object.py::test_toplevel_dunder_dataframe[pandas]",
45-
"test_dataframe_object.py::test_toplevel_dunder_dataframe[vaex]",
46-
"test_dataframe_object.py::test_toplevel_dunder_dataframe[modin]",
47-
"test_dataframe_object.py::test_dunder_dataframe[pandas]",
48-
"test_dataframe_object.py::test_dunder_dataframe[modin]",
49-
# vaex's interchange dataframe doesn't have __dataframe__()
42+
# vaex's and cudf's interchange dataframe doesn't have __dataframe__()
43+
# See https://github.com/data-apis/dataframe-api/issues/80
5044
"test_dataframe_object.py::test_dunder_dataframe[vaex]",
5145
"test_signatures.py::test_dataframe_method[vaex-__dataframe__]",
46+
"test_dataframe_object.py::test_dunder_dataframe[cudf]",
47+
"test_signatures.py::test_dataframe_method[cudf-__dataframe__]",
48+
# https://github.com/rapidsai/cudf/issues/11320
49+
"test_signatures.py::test_buffer_method[cudf-__dlpack__]",
50+
"test_signatures.py::test_buffer_method[cudf-__dlpack_device__]",
5251
# https://github.com/vaexio/vaex/issues/2083
5352
# https://github.com/vaexio/vaex/issues/2093
5453
# https://github.com/vaexio/vaex/issues/2113
@@ -59,11 +58,13 @@ def pytest_configure(config):
5958
"test_column_object.py::test_size[vaex]",
6059
# https://github.com/vaexio/vaex/issues/2118
6160
"test_column_object.py::test_dtype[vaex]",
62-
# Raises TypeError as opposed to RuntimeError, although this is the
63-
# behaviour that should be in the spec soon.
61+
# Raises RuntimeError, which is technically correct, but the spec will
62+
# require TypeError soon.
6463
# See https://github.com/data-apis/dataframe-api/pull/74
65-
"test_column_object.py::test_describe_categorical[pandas]",
64+
"test_column_object.py::test_describe_categorical[modin]",
65+
# https://github.com/vaexio/vaex/issues/2113
6666
"test_column_object.py::test_describe_categorical[vaex]",
67+
# https://github.com/rapidsai/cudf/issues/11332
6768
"test_column_object.py::test_describe_categorical[cudf]",
6869
# https://github.com/pandas-dev/pandas/issues/47789
6970
"test_column_object.py::test_null_count[pandas]",
@@ -79,9 +80,13 @@ def pytest_configure(config):
7980
"test_column_object.py::test_get_buffers[cudf]",
8081
]
8182

83+
r_cudf_roundtrip = re.compile(r"test_from_dataframe_roundtrip\[.*cudf.*\]")
84+
8285

8386
def pytest_collection_modifyitems(config, items):
8487
if config.getoption("--ci"):
8588
for item in items:
8689
if any(id_ in item.nodeid for id_ in ci_failing_ids):
8790
item.add_marker(pytest.mark.xfail())
91+
elif r_cudf_roundtrip.search(item.nodeid):
92+
item.add_marker(pytest.mark.skip("TODO"))

tests/test_column_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_describe_categorical(libinfo: LibraryInfo, data: st.DataObject):
9999
if mapping is not None:
100100
assert isinstance(mapping, dict)
101101
else:
102-
with pytest.raises(RuntimeError):
102+
with pytest.raises(TypeError):
103103
col.describe_categorical
104104

105105

tests/test_dataframe_object.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,14 @@
1111
def test_toplevel_dunder_dataframe(libinfo: LibraryInfo, data: st.DataObject):
1212
df = data.draw(libinfo.toplevel_dataframes(), label="df")
1313
assert hasattr(df, "__dataframe__")
14-
out = df.__dataframe__()
15-
assert isinstance(out, dict)
16-
assert hasattr(out, "dataframe")
17-
assert hasattr(out, "version")
14+
df.__dataframe__()
1815

1916

2017
@given(data=st.data())
2118
def test_dunder_dataframe(libinfo: LibraryInfo, data: st.DataObject):
2219
df = data.draw(libinfo.interchange_dataframes(), label="df")
2320
assert hasattr(df, "__dataframe__")
24-
out = df.__dataframe__()
25-
assert isinstance(out, dict)
26-
assert hasattr(out, "dataframe")
27-
assert hasattr(out, "version")
21+
df.__dataframe__()
2822

2923

3024
@given(data=st.data())

tests/wrappers.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ class LibraryInfo(NamedTuple):
1919
mock_to_toplevel: Callable[[MockDataFrame], TopLevelDataFrame]
2020
from_dataframe: Callable[[TopLevelDataFrame], DataFrame]
2121
frame_equal: Callable[[TopLevelDataFrame, DataFrame], bool]
22-
toplevel_to_interchange: Callable[[TopLevelDataFrame], DataFrame] = lambda df: (
23-
df.__dataframe__()["dataframe"]
24-
)
2522
exclude_dtypes: List[NominalDtype] = []
2623
allow_zero_cols: bool = True
2724
allow_zero_rows: bool = True
2825

2926
def mock_to_interchange(self, mock_dataframe: MockDataFrame) -> DataFrame:
30-
return self.toplevel_to_interchange(self.mock_to_toplevel(mock_dataframe))
27+
toplevel_df = self.mock_to_toplevel(mock_dataframe)
28+
return toplevel_df.__dataframe__()
3129

3230
@property
3331
def mock_dataframes_kwargs(self) -> Dict[str, Any]:
@@ -44,7 +42,7 @@ def toplevel_dataframes(self) -> st.SearchStrategy[TopLevelDataFrame]:
4442
return self.mock_dataframes().map(self.mock_to_toplevel)
4543

4644
def interchange_dataframes(self) -> st.SearchStrategy[TopLevelDataFrame]:
47-
return self.toplevel_dataframes().map(self.toplevel_to_interchange)
45+
return self.toplevel_dataframes().map(lambda df: df.__dataframe__())
4846

4947
def __repr__(self) -> str:
5048
return f"LibraryInfo(<{self.name}>)"
@@ -82,7 +80,6 @@ def pandas_mock_to_toplevel(mock_df: MockDataFrame) -> pd.DataFrame:
8280
mock_to_toplevel=pandas_mock_to_toplevel,
8381
from_dataframe=pandas_from_dataframe,
8482
frame_equal=lambda df1, df2: df1.equals(df2),
85-
toplevel_to_interchange=lambda df: df.__dataframe__(),
8683
exclude_dtypes=[NominalDtype.DATETIME64NS],
8784
)
8885
libinfo_params.append(pytest.param(pandas_libinfo, id=pandas_libinfo.name))
@@ -140,7 +137,6 @@ def vaex_frame_equal(df1, df2) -> bool:
140137
mock_to_toplevel=vaex_mock_to_toplevel,
141138
from_dataframe=vaex_from_dataframe,
142139
frame_equal=vaex_frame_equal,
143-
toplevel_to_interchange=lambda df: df.__dataframe__(),
144140
exclude_dtypes=[NominalDtype.DATETIME64NS],
145141
# https://github.com/vaexio/vaex/issues/2094
146142
allow_zero_cols=False,
@@ -220,7 +216,6 @@ def modin_frame_equal(df1: mpd.DataFrame, df2: mpd.DataFrame) -> bool:
220216
mock_to_toplevel=modin_mock_to_toplevel,
221217
from_dataframe=modin_from_dataframe,
222218
frame_equal=modin_frame_equal,
223-
toplevel_to_interchange=lambda df: df.__dataframe__(),
224219
# https://github.com/modin-project/modin/issues/4654
225220
# https://github.com/modin-project/modin/issues/4652
226221
exclude_dtypes=[
@@ -297,7 +292,6 @@ def cudf_mock_to_toplevel(mock_df: MockDataFrame) -> cudf.DataFrame:
297292
mock_to_toplevel=cudf_mock_to_toplevel,
298293
from_dataframe=cudf_from_dataframe,
299294
frame_equal=lambda df1, df2: df1.equals(df2), # NaNs considered equal
300-
toplevel_to_interchange=lambda df: df.__dataframe__(),
301295
exclude_dtypes=[NominalDtype.DATETIME64NS],
302296
)
303297
libinfo_params.append(pytest.param(cupy_libinfo, id=cupy_libinfo.name))

0 commit comments

Comments
 (0)