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
[FIX] force ordered output of _sanitize_reorder
to match regex in test
#3751
Conversation
_sanitize_reorder
to match regex in test
👋 @Remi-Gau Thanks for creating a PR! Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft. Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.
For new features:
For bug fixes:
We will review it as quick as possible, feel free to ping us with questions if needed. |
Codecov Report
@@ Coverage Diff @@
## main #3751 +/- ##
=======================================
Coverage 91.60% 91.60%
=======================================
Files 139 139
Lines 16589 16594 +5
Branches 3242 3244 +2
=======================================
+ Hits 15196 15201 +5
Misses 1390 1390
Partials 3 3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -89,8 +89,7 @@ def test_sanitize_reorder(reorder): | |||
def test_sanitize_reorder_error(reorder): | |||
from ..matrix_plotting import _sanitize_reorder | |||
with pytest.raises(ValueError, | |||
match=("Parameter reorder needs to be " | |||
f"one of {VALID_REORDER_VALUES}")): | |||
match=("Parameter reorder needs to be ")): |
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.
My dirty fix is to make the regex less strict.
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.
Yea I think that's ok. But do VALID_REORDER_ARGS and VALID_REORDER_VALUES need to be an unordered set? Can we just use a list instead?
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.
I thought I had tried in the first commit but now realizing that the square brackets would turn add some "grouping" to the regex...
FAILED nilearn/plotting/tests/test_matrix_plotting.py::test_sanitize_reorder_error[None] - AssertionError: Regex pattern did not match.
Regex: "Parameter reorder needs to be one of [False, True, 'average', 'single', 'complete']"
Input: "Parameter reorder needs to be one of [False, True, 'average', 'single', 'complete']."
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.
Ok right. you could maybe use re.escape("Parameter reorder needs to be one of [False, True, 'average', 'single', 'complete'].")
but if you feel it's not worth the time we just go with the general pattern solution.
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.
decided to stringify everything
@ymzayek |
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.
I think it's ok like this, thanks!
OK merging now since so we can avoid having this fail in other PRs |
Thanks for the tips @ymzayek |
Closes #3750
Changes proposed in this pull request: