From 9bf53c355bd92dd7ca4c107520783c0db797a65b Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Fri, 31 May 2024 10:54:17 +0000 Subject: [PATCH] Add more tests --- python/cudf_polars/pyproject.toml | 2 +- python/cudf_polars/tests/__init__.py | 6 ++++ .../cudf_polars/tests/expressions/__init__.py | 6 ++++ .../tests/expressions/test_distinct.py | 36 +++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 python/cudf_polars/tests/__init__.py create mode 100644 python/cudf_polars/tests/expressions/__init__.py create mode 100644 python/cudf_polars/tests/expressions/test_distinct.py diff --git a/python/cudf_polars/pyproject.toml b/python/cudf_polars/pyproject.toml index 49ecd7080b9..e50ee76a9b9 100644 --- a/python/cudf_polars/pyproject.toml +++ b/python/cudf_polars/pyproject.toml @@ -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 diff --git a/python/cudf_polars/tests/__init__.py b/python/cudf_polars/tests/__init__.py new file mode 100644 index 00000000000..4611d642f14 --- /dev/null +++ b/python/cudf_polars/tests/__init__.py @@ -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] = [] diff --git a/python/cudf_polars/tests/expressions/__init__.py b/python/cudf_polars/tests/expressions/__init__.py new file mode 100644 index 00000000000..4611d642f14 --- /dev/null +++ b/python/cudf_polars/tests/expressions/__init__.py @@ -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] = [] diff --git a/python/cudf_polars/tests/expressions/test_distinct.py b/python/cudf_polars/tests/expressions/test_distinct.py new file mode 100644 index 00000000000..22865a7ce22 --- /dev/null +++ b/python/cudf_polars/tests/expressions/test_distinct.py @@ -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)