-
Notifications
You must be signed in to change notification settings - Fork 912
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
pylibcudf.DataType
serialization (#17352)
For the multi-GPU cudf-polars work serializing `pylibcudf.DataType` will be required. This change implements the `__reduce__` method and add appropriate tests. Authors: - Peter Andreas Entschev (https://github.com/pentschev) Approvers: - Matthew Murray (https://github.com/Matt711) - Lawrence Mitchell (https://github.com/wence-) URL: #17352
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
import pickle | ||
|
||
import pytest | ||
|
||
from pylibcudf import DataType | ||
from pylibcudf.types import TypeId | ||
|
||
|
||
@pytest.fixture(params=list(TypeId)) | ||
def dtype(request): | ||
tid = request.param | ||
if tid in {TypeId.DECIMAL32, TypeId.DECIMAL64, TypeId.DECIMAL128}: | ||
scale = 5 | ||
else: | ||
scale = 0 | ||
return DataType(tid, scale) | ||
|
||
|
||
def test_reduce(dtype): | ||
(typ, (tid, scale)) = dtype.__reduce__() | ||
assert typ is DataType | ||
assert tid == dtype.id() | ||
assert scale == dtype.scale() | ||
|
||
|
||
def test_pickle(dtype): | ||
assert dtype == pickle.loads(pickle.dumps(dtype)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters