Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wence- committed Jun 4, 2024
1 parent 344dd58 commit 9bf53c3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/cudf_polars/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ ignore = [
fixable = ["ALL"]

[tool.ruff.lint.per-file-ignores]
"**/tests/**/test_*.py" = ["D", "INP"]
"**/tests/**/*.py" = ["D"]

[tool.ruff.lint.flake8-pytest-style]
# https://docs.astral.sh/ruff/settings/#lintflake8-pytest-style
Expand Down
6 changes: 6 additions & 0 deletions python/cudf_polars/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

__all__: list[str] = []
6 changes: 6 additions & 0 deletions python/cudf_polars/tests/expressions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

__all__: list[str] = []
36 changes: 36 additions & 0 deletions python/cudf_polars/tests/expressions/test_distinct.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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.fixture(params=[False, True], ids=["no-nulls", "nulls"])
def nullable(request):
return request.param


@pytest.fixture(
params=["is_first_distinct", "is_last_distinct", "is_unique", "is_duplicated"]
)
def op(request):
return request.param


@pytest.fixture
def df(nullable):
values: list[int | None] = [1, 2, 3, 1, 1, 7, 3, 2, 7, 8, 1]
if nullable:
values[1] = None
values[4] = None
return pl.LazyFrame({"a": values})


def test_expr_distinct(df, op):
expr = getattr(pl.col("a"), op)()
query = df.select(expr)
assert_gpu_result_equal(query)

0 comments on commit 9bf53c3

Please sign in to comment.