Skip to content

Commit 39ed0f0

Browse files
lmeyerovclaude
andcommitted
test(gfql/cudf): CPU unit coverage for _cudf_regex_prep (pure pattern transform)
_cudf_regex_prep is a pure string transform (no cuDF required), but its only tests were cuDF-gated, so CPU CI left the new lines uncovered and #1675's changed-line-coverage gate fell to 65.9%. Add direct unit tests for every branch: non-str/no-flag passthrough, leading (?i)/(?ii) -> case-fold, other inline flags -> honest NotImplementedError. Remaining uncovered lines are the is_cudf execution branches (GPU-only; covered by the dgx parity pass). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4f691fa commit 39ed0f0

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

graphistry/tests/compute/predicates/test_str.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,3 +856,32 @@ def test_boundary_string_tuple_pandas_cudf_parity(
856856
pd.testing.assert_series_equal(result_pandas, result_cudf)
857857
except AssertionError as e:
858858
pytest.fail(f"Parity check failed for {name} {predicate}: {e}")
859+
860+
861+
class TestCudfRegexPrep:
862+
"""_cudf_regex_prep is a pure pattern transform (no cuDF needed): libcudf rejects
863+
inline flag groups, so a leading (?i) folds to the case=False path and any other
864+
flag declines honestly. Direct CPU coverage of every branch (viz-filter #1673)."""
865+
866+
def test_non_string_passthrough(self):
867+
from graphistry.compute.predicates.str import _cudf_regex_prep
868+
assert _cudf_regex_prep(123, True) == (123, True)
869+
assert _cudf_regex_prep(None, False) == (None, False)
870+
871+
def test_no_inline_flags_passthrough(self):
872+
from graphistry.compute.predicates.str import _cudf_regex_prep
873+
assert _cudf_regex_prep("al.*", True) == ("al.*", True)
874+
assert _cudf_regex_prep("a(?:b|c)d", True) == ("a(?:b|c)d", True) # (?: not a flag group
875+
876+
def test_leading_case_flag_folds(self):
877+
from graphistry.compute.predicates.str import _cudf_regex_prep
878+
assert _cudf_regex_prep("(?i)Al.*", True) == ("Al.*", False)
879+
assert _cudf_regex_prep("(?i)x", False) == ("x", False)
880+
assert _cudf_regex_prep("(?ii)x", True) == ("x", False) # repeated i still i-only
881+
882+
def test_other_inline_flags_decline(self):
883+
import pytest as _pytest
884+
from graphistry.compute.predicates.str import _cudf_regex_prep
885+
for pat in ["(?m)^a", "(?s).*", "(?im)a", "(?x) a b"]:
886+
with _pytest.raises(NotImplementedError):
887+
_cudf_regex_prep(pat, True)

0 commit comments

Comments
 (0)