Skip to content

Commit

Permalink
Fix Flake8 errors overlooked when merging PR nilearn#2028 (Plot conne…
Browse files Browse the repository at this point in the history
…ctome strength) (nilearn#2174)

* Fix Flake8 errors overlooked when merging PR nilearn#2028 (Plot connectome strength)

* Ignore linting for W508

* Corrected linter code
  • Loading branch information
kchawla-pi committed Oct 14, 2019
1 parent b5726d6 commit bc6a019
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/03_connectivity/plot_sphere_based_connectome.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
'Posterior Cingulate Cortex',
'Left Temporoparietal junction',
'Right Temporoparietal junction',
'Medial prefrontal cortex'
'Medial prefrontal cortex',
]

##########################################################################
Expand Down
4 changes: 2 additions & 2 deletions nilearn/plotting/img_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ def plot_connectome_strength(adjacency_matrix, node_coords, node_size="auto",
adjacency_matrix = np.nan_to_num(adjacency_matrix)

adjacency_matrix_shape = adjacency_matrix.shape
if (len(adjacency_matrix_shape) != 2 or
if (len(adjacency_matrix_shape) != 2 or # noqa: W504
adjacency_matrix_shape[0] != adjacency_matrix_shape[1]):
raise ValueError(
"'adjacency_matrix' is supposed to have shape (n, n)."
Expand Down Expand Up @@ -1426,7 +1426,7 @@ def plot_connectome_strength(adjacency_matrix, node_coords, node_size="auto",
)
# reduce alpha for the least strong regions
color[-1] = (
(region - strength_sorted.min()) *
(region - strength_sorted.min()) * # noqa: W504
(1 / (strength_sorted.max() - strength_sorted.min()))
)
# make color to be a 2D array
Expand Down
5 changes: 3 additions & 2 deletions nilearn/plotting/tests/test_img_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def test_connectome_strength():
*args, output_file=filename, **kwargs
)
assert_true(display is None)
assert_true(os.path.isfile(filename) and
assert_true(os.path.isfile(filename) and # noqa: W504
os.path.getsize(filename) > 0)
finally:
os.remove(filename)
Expand Down Expand Up @@ -659,7 +659,8 @@ def test_plot_connectome_strength_exceptions():
node_coords[:, 2], **kwargs)

wrong_adjacency_matrix = np.zeros((3, 3))
assert_raises_regex(ValueError, r'Shape mismatch.+\(3L?, 3L?\).+\(2L?, 3L?\)',
assert_raises_regex(ValueError,
r'Shape mismatch.+\(3L?, 3L?\).+\(2L?, 3L?\)',
plot_connectome_strength,
wrong_adjacency_matrix, node_coords, **kwargs)

Expand Down

0 comments on commit bc6a019

Please sign in to comment.