Skip to content

Commit

Permalink
relax regex for warning on sanitize reorder error
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Jun 19, 2023
1 parent b2562d6 commit 13fa10a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
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_tri(tri):

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

0 comments on commit 13fa10a

Please sign in to comment.