Skip to content

Commit

Permalink
fix error when colorscale given boolean array (#2193)
Browse files Browse the repository at this point in the history
* fix error when colorscale given boolean array

* add comment
  • Loading branch information
jeromedockes authored and kchawla-pi committed Oct 28, 2019
1 parent 053e5a8 commit bd27cf5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
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)
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)


def test_colorscale_threshold_0():
Expand Down

0 comments on commit bd27cf5

Please sign in to comment.