-
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.
Implement translation for some unary functions and a single datetime …
…extraction (#16173) - Closes #16169 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Thomas Li (https://github.com/lithomas1) URL: #16173
- Loading branch information
Showing
7 changed files
with
228 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
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,32 @@ | ||
# 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 | ||
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