Skip to content

Commit 4f13176

Browse files
committed
Add more smoke tests
Signed-off-by: Vasily Litvinov <vasilij.n.litvinov@intel.com>
1 parent bd4f6f2 commit 4f13176

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

pandas/tests/api/test_protocol.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,41 @@ def test_dataframe(df_from_dict):
7272
assert dfX.column_names() == ["x", "y", "z"]
7373
assert dfX.select_columns((0, 2)).column_names() == dfX.select_columns_by_name(("x", "z")).column_names()
7474

75-
@pytest.mark.parametrize(["size", "n_chunks"],
76-
[(10, 3), (12, 3), (12, 5)]
77-
)
78-
def test_chunks(size, n_chunks, df_from_dict):
75+
@pytest.mark.parametrize(["size", "n_chunks"], [(10, 3), (12, 3), (12, 5)])
76+
def test_df_get_chunks(size, n_chunks, df_from_dict):
7977
df = df_from_dict({"x": list(range(size))})
8078
dfX = df.__dataframe__()
8179
chunks = list(dfX.get_chunks(n_chunks))
8280
assert len(chunks) == n_chunks
8381
assert sum(chunk.num_rows() for chunk in chunks) == size
8482

83+
@pytest.mark.parametrize(["size", "n_chunks"], [(10, 3), (12, 3), (12, 5)])
84+
def test_column_get_chunks(size, n_chunks, df_from_dict):
85+
df = df_from_dict({"x": list(range(size))})
86+
dfX = df.__dataframe__()
87+
chunks = list(dfX.get_column(0).get_chunks(n_chunks))
88+
assert len(chunks) == n_chunks
89+
assert sum(chunk.size for chunk in chunks) == size
8590

86-
def test_get_chunks(df_from_dict):
87-
df = df_from_dict({"x": [1]})
91+
def test_get_columns(df_from_dict):
92+
df = df_from_dict({"a": [0, 1], "b": [2.5, 3.5]})
93+
dfX = df.__dataframe__()
94+
for colX in dfX.get_columns():
95+
assert colX.size == 2
96+
assert colX.num_chunks() == 1
97+
assert dfX.get_column(0).dtype[0] == 0
98+
assert dfX.get_column(1).dtype[0] == 2
99+
100+
def test_buffer(df_from_dict):
101+
df = df_from_dict({"a": [0, 1]})
88102
dfX = df.__dataframe__()
89-
assert len(list(dfX.get_chunks())) == 1
103+
colX = dfX.get_column(0)
104+
bufX = colX.get_buffers()
105+
106+
dataBuf, dataDtype = bufX['data']
107+
108+
assert dataBuf.bufsize > 0
109+
assert dataBuf.ptr != 0
110+
assert dataBuf.__dlpack_device__
111+
112+
assert dataDtype[0] == 0

0 commit comments

Comments
 (0)