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

fix error when colorscale given boolean array #2193

Merged
merged 3 commits into from
Oct 28, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nilearn/plotting/js_plotting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def colorscale(cmap, values, threshold=None, symmetric_cmap=True,
vmin = 0
if vmax is None:
vmax = abs_values.max()
# cast to float to avoid TypeError if vmax is a numpy boolean
vmax = float(vmax)
Copy link
Collaborator

Choose a reason for hiding this comment

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

A comment here, why we are typecasting this to float, so future maintainers will have an easier time understanding it.

if symmetric_cmap:
vmin = - vmax
if vmin is None:
Expand Down
1 change: 1 addition & 0 deletions nilearn/plotting/tests/test_js_plotting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def test_colorscale_no_threshold():
assert colors['cmap'].N == 256
assert (colors['norm'].vmax, colors['norm'].vmin) == (13, -13)
assert colors['abs_threshold'] is None
colors = js_plotting_utils.colorscale(cmap, values > 0, .5)
Copy link
Member

Choose a reason for hiding this comment

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

This does not really test the new feature, does it ?



def test_colorscale_threshold_0():
Expand Down