forked from rapidsai/cudf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Translate round and unique unary operations
And add evaluation handlers.
- Loading branch information
Showing
6 changed files
with
160 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from __future__ import annotations | ||
|
||
import math | ||
|
||
import pytest | ||
|
||
import polars as pl | ||
|
||
from cudf_polars.testing.asserts import assert_gpu_result_equal | ||
|
||
|
||
@pytest.fixture(params=[pl.Float32, pl.Float64]) | ||
def dtype(request): | ||
return request.param | ||
|
||
|
||
@pytest.fixture(params=[False, True], ids=["no_nulls", "nulls"]) | ||
def with_nulls(request): | ||
return request.param | ||
|
||
|
||
@pytest.fixture | ||
def df(dtype, with_nulls): | ||
a = [-math.e, 10, 22.5, 1.5, 2.5, -1.5, math.pi, 8] | ||
if with_nulls: | ||
a[2] = None | ||
a[-1] = None | ||
return pl.LazyFrame({"a": a}, schema={"a": dtype}) | ||
|
||
|
||
@pytest.mark.parametrize("decimals", [0, 2, 4]) | ||
def test_round(df, decimals): | ||
q = df.select(pl.col("a").round(decimals=decimals)) | ||
|
||
assert_gpu_result_equal(q, check_exact=False) |
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,24 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
import polars as pl | ||
|
||
from cudf_polars.testing.asserts import assert_gpu_result_equal | ||
|
||
|
||
@pytest.mark.parametrize("maintain_order", [False, True], ids=["unstable", "stable"]) | ||
@pytest.mark.parametrize("pre_sorted", [False, True], ids=["unsorted", "sorted"]) | ||
def test_unique(maintain_order, pre_sorted): | ||
ldf = pl.DataFrame( | ||
{ | ||
"b": [1.5, 2.5, None, 1.5, 3, float("nan"), 3], | ||
} | ||
).lazy() | ||
if pre_sorted: | ||
ldf = ldf.sort("b") | ||
|
||
query = ldf.select(pl.col("b").unique(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