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

[MAINT] relax regex for warning on sanitize reorder error #3766

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion nilearn/plotting/matrix_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

def _sanitize_reorder(reorder):
"""Help for plot_matrix."""
VALID_REORDER_ARGS = {True, False, 'single', 'complete', 'average'}
VALID_REORDER_ARGS = (True, False, 'single', 'complete', 'average')

Check warning on line 102 in nilearn/plotting/matrix_plotting.py

View check run for this annotation

Codecov / codecov/patch

nilearn/plotting/matrix_plotting.py#L102

Added line #L102 was not covered by tests
if reorder not in VALID_REORDER_ARGS:
param_to_print = []
for item in VALID_REORDER_ARGS:
Expand Down
11 changes: 2 additions & 9 deletions nilearn/plotting/tests/test_matrix_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_sanitize_tri_error(tri):
_sanitize_tri(tri)


VALID_REORDER_VALUES = {True, False, 'single', 'complete', 'average'}
VALID_REORDER_VALUES = (True, False, 'single', 'complete', 'average')


@pytest.mark.parametrize("reorder", VALID_REORDER_VALUES)
Expand All @@ -89,15 +89,8 @@ def test_sanitize_reorder(reorder):
@pytest.mark.parametrize("reorder", [None, "foo", 2])
def test_sanitize_reorder_error(reorder):
from ..matrix_plotting import _sanitize_reorder
param_to_print = []
for item in VALID_REORDER_VALUES:
if isinstance(item, str):
param_to_print.append(f'"{item}"')
else:
param_to_print.append(str(item))
with pytest.raises(ValueError,
match=("Parameter reorder needs to be one of:\\n"
f"{', '.join(param_to_print)}.")):
match=("Parameter reorder needs to be one of")):
_sanitize_reorder(reorder)


Expand Down