-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt to updates and start building out tests
- Loading branch information
Showing
6 changed files
with
160 additions
and
58 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
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
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
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
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,25 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import polars as pl | ||
import pytest | ||
|
||
from cudf_polars.testing.asserts import assert_gpu_result_equal | ||
|
||
|
||
@pytest.mark.parametrize("subset", [None, ["a"], ["a", "b"], ["b", "c"]]) | ||
@pytest.mark.parametrize("keep", ["any", "none", "first", "last"]) | ||
@pytest.mark.parametrize( | ||
"maintain_order", [False, True], ids=["unstable", "stable"] | ||
) | ||
def test_distinct(subset, keep, maintain_order): | ||
ldf = pl.DataFrame( | ||
{ | ||
"a": [1, 2, 1, 3, 5, None, None], | ||
"b": [1.5, 2.5, None, 1.5, 3, float("nan"), 3], | ||
"c": [True, True, True, True, False, False, True], | ||
} | ||
).lazy() | ||
|
||
query = ldf.unique(subset=subset, keep=keep, maintain_order=maintain_order) | ||
assert_gpu_result_equal(query, check_row_order=maintain_order) |
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,42 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import polars as pl | ||
import pytest | ||
|
||
from cudf_polars.testing.asserts import assert_gpu_result_equal | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"sort_keys", | ||
[ | ||
(pl.col("a"),), | ||
pytest.param( | ||
(pl.col("d").abs(),), | ||
marks=pytest.mark.xfail(reason="abs not yet implemented"), | ||
), | ||
(pl.col("a"), pl.col("d")), | ||
(pl.col("b"),), | ||
], | ||
) | ||
@pytest.mark.parametrize("nulls_last", [False, True]) | ||
@pytest.mark.parametrize( | ||
"maintain_order", [False, True], ids=["unstable", "stable"] | ||
) | ||
def test_sort(sort_keys, nulls_last, maintain_order): | ||
ldf = pl.DataFrame( | ||
{ | ||
"a": [1, 2, 1, 3, 5, None, None], | ||
"b": [1.5, 2.5, None, 1.5, 3, float("nan"), 3], | ||
"c": [True, True, True, True, False, False, True], | ||
"d": [1, 2, -1, 10, 6, -1, -7], | ||
} | ||
).lazy() | ||
|
||
query = ldf.sort( | ||
*sort_keys, | ||
descending=True, | ||
nulls_last=nulls_last, | ||
maintain_order=maintain_order, | ||
) | ||
assert_gpu_result_equal(query, check_row_order=maintain_order) |