-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plumb pylibcudf strings contains_re
through cudf_polars
#15918
Merged
rapids-bot
merged 27 commits into
rapidsai:branch-24.08
from
brandon-b-miller:cudf-polars-str-contains
Jun 13, 2024
Merged
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
05d1eb4
initial
brandon-b-miller 004ae1d
Merge branch 'branch-24.08' into pylibcudf-strings-contains
brandon-b-miller 9a3f19d
merge/resolve
brandon-b-miller 87341d4
one test
brandon-b-miller 6d50191
tests, fixes
brandon-b-miller e35cd9a
declaration
brandon-b-miller 69ad703
Merge branch 'branch-24.08' into pylibcudf-strings-contains
brandon-b-miller 83178c9
docs, style
brandon-b-miller 758755c
type create more strongly
brandon-b-miller 98aeefa
add more tests
brandon-b-miller 936e412
style
brandon-b-miller b15588a
regex program tests
brandon-b-miller b5a68c5
Merge branch 'branch-24.08' into pylibcudf-strings-contains
brandon-b-miller 4b6a393
polars contains_re plumbing
brandon-b-miller 6c125cb
refactor expr
brandon-b-miller 9fb3a2b
add tests for invalid regex
brandon-b-miller 0463688
merge latest/resolve conflicts
brandon-b-miller 7543726
cleanup
brandon-b-miller 42b158f
Address reviews
brandon-b-miller 39b57ca
merge latest/resolve conflicts
brandon-b-miller e3fb170
refactor logic
brandon-b-miller da08309
merge latest/resolve
brandon-b-miller e45fbed
add literal column tests, support it, refactor logic
brandon-b-miller 22e1031
add tests, refactor
brandon-b-miller 4b643a7
pacify mypy
brandon-b-miller 5533e5b
Make type-narrowing a no-op if run with `-O`
wence- ee42757
Merge branch 'branch-24.08' into cudf-polars-str-contains
wence- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from __future__ import annotations | ||
|
||
from functools import partial | ||
|
||
import pytest | ||
|
||
import polars as pl | ||
|
||
from cudf_polars.callback import execute_with_cudf | ||
from cudf_polars.testing.asserts import assert_gpu_result_equal | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"substr", | ||
[ | ||
"A", | ||
"de", | ||
".*", | ||
"^a", | ||
"^A", | ||
"[^a-z]", | ||
"[a-z]{3,}", | ||
"^[A-Z]{2,}", | ||
"j|u", | ||
], | ||
brandon-b-miller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
def test_contains(substr): | ||
ldf = pl.DataFrame( | ||
{"a": ["AbC", "de", "FGHI", "j", "kLm", "nOPq", None, "RsT", None, "uVw"]} | ||
).lazy() | ||
|
||
query = ldf.select(pl.col("a").str.contains(substr)) | ||
assert_gpu_result_equal(query) | ||
|
||
|
||
@pytest.mark.parametrize("pat", ["["]) | ||
def test_contains_invalid(pat): | ||
ldf = pl.DataFrame( | ||
{"a": ["AbC", "de", "FGHI", "j", "kLm", "nOPq", None, "RsT", None, "uVw"]} | ||
).lazy() | ||
|
||
query = ldf.select(pl.col("a").str.contains(pat)) | ||
|
||
with pytest.raises(pl.exceptions.ComputeError): | ||
query.collect() | ||
with pytest.raises(pl.exceptions.ComputeError): | ||
query.collect(post_opt_callback=partial(execute_with_cudf, raise_on_fail=True)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for literal contains, can we support columns as patterns? libcudf does: https://docs.rapids.ai/api/libcudf/stable/group__strings__find#ga9acbc587765007c5e35811c07e990b03
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supported this in e45fbed