diff --git a/nilearn/plotting/js_plotting_utils.py b/nilearn/plotting/js_plotting_utils.py index 5e41e2ae54..90e4efa222 100644 --- a/nilearn/plotting/js_plotting_utils.py +++ b/nilearn/plotting/js_plotting_utils.py @@ -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: diff --git a/nilearn/plotting/tests/test_js_plotting_utils.py b/nilearn/plotting/tests/test_js_plotting_utils.py index 06bc608b54..ffd6555ee4 100644 --- a/nilearn/plotting/tests/test_js_plotting_utils.py +++ b/nilearn/plotting/tests/test_js_plotting_utils.py @@ -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():