Skip to content

feat: inverse kwarg added to col_vals_regex() #195

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zilto
Copy link
Contributor

@zilto zilto commented May 23, 2025

Summary

Problem

I was using the regex check, but a success was defined as "no match". In dataframe libraries, it's simple to do a logical negation using ~. Currently, pointblank doesn't provide an interface to do so.

Alternatively, reworking the regex to "find no match" adds a lot of complexity (both for writing and computing the regex). In my case, the appropriate "find no match" regex wasn't supported by polars because of regex "look around" limitations.

Solution

Now, .col_vals_regex() accepts an inverse=... kwarg to flip the match results

Work done

  • I followed the logic of inverse kwarg in row_count_match() checks
  • I added inverse to the Interrogator class, which might be undesirable
  • Now, regex checks pass the value {"pattern": "my-pattern", "inverse": False} instead of "my-pattern". I modified a test accordingly.
  • Updated signatures in docstrings (didn't add full-on example text)

Remaining TODO

  • Add tests to ensure that both inverse=True and inverse=False behave as expected
  • Ensure that the HTML snapshots appropriately render check results (maybe we need to unpack the dict?)
  • Update the HTML snapshots with the updated _ValidationInfo.values

(feel free to complete these steps if it's convenient)

Checklist

@@ -1131,14 +1135,14 @@ def regex(self) -> FrameT | Any:
pb_is_good_1=self.x[self.column].isnull() & ibis.literal(self.na_pass),
pb_is_good_2=self.x[self.column].re_search(self.pattern),
)
expr = tbl.pb_is_good_1 | tbl.pb_is_good_2
if self.inverse is True:
expr = expr.negate()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that .negate() is deprecated since ibis-frameworjk>=10.0.0. Will update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant