Skip to content

Add more tests for the dataframe interchange protocol #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions protocol/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
import pandas as pd
from pandas.api.exchange.implementation import _from_dataframe


@pytest.fixture(scope="package")
Expand All @@ -10,11 +9,3 @@ def maker(dct, is_categorical=False):
return df.astype("category") if is_categorical else df

return maker


@pytest.fixture(scope="package")
def df_from_xchg():
def maker(xchg):
return _from_dataframe(xchg)

return maker
14 changes: 6 additions & 8 deletions protocol/tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_float_int(df_from_dict):
}
)
dfX = df.__dataframe__()
columns = {"a": 0, "b": 0, "c": 2, "d": 0, "e": 20, "f": 21}
columns = [INT, INT, FLOAT, INT, BOOL, STRING]

for column, kind in columns.items():
colX = dfX.get_column_by_name(column)
Expand All @@ -46,8 +46,6 @@ def test_float_int(df_from_dict):

assert colX.dtype[0] == kind

assert dfX.get_column_by_name("c").dtype[1] == 64


def test_na_float(df_from_dict):
df = df_from_dict({"a": [1.0, math.nan, 2.0]})
Expand Down Expand Up @@ -85,10 +83,10 @@ def test_dataframe(df_from_dict):
assert dfX.num_columns() == 3
assert dfX.num_rows() == 3
assert dfX.num_chunks() == 1
assert dfX.column_names() == ["x", "y", "z"]
assert list(dfX.column_names()) == ["x", "y", "z"]
assert (
dfX.select_columns((0, 2)).column_names()
== dfX.select_columns_by_name(("x", "z")).column_names()
list(dfX.select_columns((0, 2)).column_names())
== list(dfX.select_columns_by_name(("x", "z")).column_names())
)


Expand Down Expand Up @@ -116,8 +114,8 @@ def test_get_columns(df_from_dict):
for colX in dfX.get_columns():
assert colX.size == 2
assert colX.num_chunks() == 1
assert dfX.get_column(0).dtype[0] == 0
assert dfX.get_column(1).dtype[0] == 2
assert dfX.get_column(0).dtype[0] == INT
assert dfX.get_column(1).dtype[0] == FLOAT


def test_buffer(df_from_dict):
Expand Down