Skip to content

Commit 7ba07c8

Browse files
committed
tests
1 parent 5183e35 commit 7ba07c8

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

python/cudf_polars/cudf_polars/experimental/dask_registers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def _(header: ColumnHeader, frames: tuple[memoryview, memoryview]) -> Column:
132132

133133
@sizeof_dispatch.register(Column)
134134
def _(x: Column) -> int:
135+
"""The total size of the device buffers used by the Column."""
135136
ret = 0
136137
if x.obj.data() is not None:
137138
ret += x.obj.data().nbytes
@@ -143,4 +144,5 @@ def _(x: Column) -> int:
143144

144145
@sizeof_dispatch.register(DataFrame)
145146
def _(x: DataFrame) -> int:
147+
"""The total size of the device buffers used by the DataFrame."""
146148
return sum(sizeof_dispatch(c) for c in x.columns)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
from __future__ import annotations
5+
6+
import pyarrow as pa
7+
import pytest
8+
from dask.sizeof import sizeof
9+
10+
import pylibcudf as plc
11+
12+
from cudf_polars.containers import DataFrame
13+
from cudf_polars.experimental.dask_registers import register
14+
15+
# Must register sizeof dispatch before running tests
16+
register()
17+
18+
19+
@pytest.mark.parametrize(
20+
"arrow_tbl, size",
21+
[
22+
(pa.table([]), 0),
23+
(pa.table({"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]}), 9 * 8),
24+
(pa.table({"a": [1, 2, 3]}), 3 * 8),
25+
(pa.table({"a": [1], "b": [2], "c": [3]}), 3 * 8),
26+
],
27+
)
28+
def test_dask_sizeof(arrow_tbl, size):
29+
plc_tbl = plc.interop.from_arrow(arrow_tbl)
30+
df = DataFrame.from_table(plc_tbl, names=arrow_tbl.column_names)
31+
assert sizeof(df) == size

0 commit comments

Comments
 (0)