Skip to content
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

Filter/square brackets #849

Merged

Conversation

danielhuppmann
Copy link
Member

Please confirm that this PR has done the following:

  • Tests Added
  • Documentation Added
  • Name of contributors Added to AUTHORS.rst
  • Description in RELEASE_NOTES.md Added

Description of PR

This PR fixes an issue where filtering by a string with square brackets is interpreted as regexp and doesn't work as expected.

Copy link

codecov bot commented Apr 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.0%. Comparing base (ddbb88e) to head (6b6574a).
Report is 15 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #849   +/-   ##
=====================================
  Coverage   95.0%   95.0%           
=====================================
  Files         64      63    -1     
  Lines       6134    6158   +24     
=====================================
+ Hits        5828    5851   +23     
- Misses       306     307    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@phackstock phackstock left a comment

Choose a reason for hiding this comment

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

Looks good to me, one small suggestion but good to merge either way.

pyam/str.py Outdated
@@ -4,6 +4,8 @@
import pandas as pd
from pandas.api.types import is_list_like

REGEXP_CHARACTERS = r".+()[]{}|$"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that I'd ever seen it but we can add the caret symbol as well ^, especially since you have the dollar sign:

Suggested change
REGEXP_CHARACTERS = r".+()[]{}|$"
REGEXP_CHARACTERS = r".+()[]{}|$^"

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for this comment - went through the list of regex-characters at https://docs.python.org/3/library/re.html and also added ?...

@danielhuppmann danielhuppmann merged commit 2e5c85f into IAMconsortium:main Apr 19, 2024
14 checks passed
@danielhuppmann danielhuppmann deleted the filter/square-brackets branch April 19, 2024 10:58
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.

2 participants