Hello, I am a novice programmer trying to execute the Hypespy TEMEDS tutorial so I may adapt it for my own samples. Thanks for your consideration. When attempting to follow the hyperspy TEMEDS tutorial, the following issue is triggered when trying to execute
"axes = hs.plot.plot_images((mask, pt_la * mask), axes_decor=None, colorbar=None,
label=['Mask', 'Pt Lα intensity'], cmap='viridis')"
the following error is thrown
"TypeError Traceback (most recent call last)
Cell In[39], line 1
----> 1 axes = hs.plot.plot_images((mask, pt_la * mask), axes_decor=None, colorbar=None,
2 label=['Mask', 'Pt Lα intensity'], cmap='viridis')
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/hyperspy/drawing/utils.py:1063, in plot_images(images, cmap, no_nans, per_row, label, labelwrap, suptitle, suptitle_fontsize, colorbar, centre_colormap, scalebar, scalebar_color, axes_decor, padding, tight_layout, aspect, min_asp, namefrac_thresh, fig, vmin, vmax, overlay, colors, alphas, legend_picking, legend_loc, pixel_size_factor, **kwargs)
1061 _vmin = vmin[idx] if isinstance(vmin, (tuple, list)) else vmin
1062 _vmax = vmax[idx] if isinstance(vmax, (tuple, list)) else vmax
-> 1063 _vmin, _vmax = contrast_stretching(data, _vmin, _vmax)
1064 if centre:
1065 _vmin, _vmax = centre_colormap_values(_vmin, _vmax)
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/hyperspy/drawing/utils.py:91, in contrast_stretching(data, vmin, vmax)
88 # If vmin, vmax are float or int, we keep the value, if not we calculate
89 # the precentile value
90 if not isinstance(vmin, (float, int)):
---> 91 vmin = np.nanpercentile(data, _parse_value(vmin, 'vmin'))
92 if not isinstance(vmax, (float, int)):
93 vmax = np.nanpercentile(data, _parse_value(vmax, 'vmax'))
File <array_function internals>:180, in nanpercentile(*args, **kwargs)
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/nanfunctions.py:1384, in nanpercentile(a, q, axis, out, overwrite_input, method, keepdims, interpolation)
1382 if not function_base._quantile_is_valid(q):
1383 raise ValueError("Percentiles must be in the range [0, 100]")
-> 1384 return _nanquantile_unchecked(
1385 a, q, axis, out, overwrite_input, method, keepdims)
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/nanfunctions.py:1559, in _nanquantile_unchecked(a, q, axis, out, overwrite_input, method, keepdims)
1557 if a.size == 0:
1558 return np.nanmean(a, axis, out=out, keepdims=keepdims)
-> 1559 r, k = function_base._ureduce(a,
1560 func=_nanquantile_ureduce_func,
1561 q=q,
1562 axis=axis,
1563 out=out,
1564 overwrite_input=overwrite_input,
1565 method=method)
1566 if keepdims and keepdims is not np._NoValue:
1567 return r.reshape(q.shape + k)
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:3725, in _ureduce(a, func, **kwargs)
3722 else:
3723 keepdim = (1,) * a.ndim
-> 3725 r = func(a, **kwargs)
3726 return r, keepdim
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/nanfunctions.py:1581, in _nanquantile_ureduce_func(a, q, axis, out, overwrite_input, method)
1579 if axis is None or a.ndim == 1:
1580 part = a.ravel()
-> 1581 result = _nanquantile_1d(part, q, overwrite_input, method)
1582 else:
1583 result = np.apply_along_axis(_nanquantile_1d, axis, a, q,
1584 overwrite_input, method)
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/nanfunctions.py:1607, in _nanquantile_1d(arr1d, q, overwrite_input, method)
1603 if arr1d.size == 0:
1604 # convert to scalar
1605 return np.full(q.shape, np.nan, dtype=arr1d.dtype)[()]
-> 1607 return function_base._quantile_unchecked(
1608 arr1d, q, overwrite_input=overwrite_input, method=method)
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:4424, in _quantile_unchecked(a, q, axis, out, overwrite_input, method, keepdims)
4416 def _quantile_unchecked(a,
4417 q,
4418 axis=None,
(...)
4421 method="linear",
4422 keepdims=False):
4423 """Assumes that q is in [0, 1], and is an ndarray"""
-> 4424 r, k = _ureduce(a,
4425 func=_quantile_ureduce_func,
4426 q=q,
4427 axis=axis,
4428 out=out,
4429 overwrite_input=overwrite_input,
4430 method=method)
4431 if keepdims:
4432 return r.reshape(q.shape + k)
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:3725, in _ureduce(a, func, **kwargs)
3722 else:
3723 keepdim = (1,) * a.ndim
-> 3725 r = func(a, **kwargs)
3726 return r, keepdim
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:4593, in _quantile_ureduce_func(a, q, axis, out, overwrite_input, method)
4591 else:
4592 arr = a.copy()
-> 4593 result = _quantile(arr,
4594 quantiles=q,
4595 axis=axis,
4596 method=method,
4597 out=out)
4598 return result
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:4710, in _quantile(arr, quantiles, axis, method, out)
4708 result_shape = virtual_indexes.shape + (1,) * (arr.ndim - 1)
4709 gamma = gamma.reshape(result_shape)
-> 4710 result = _lerp(previous,
4711 next,
4712 gamma,
4713 out=out)
4714 if np.any(slices_having_nans):
4715 if result.ndim == 0 and out is None:
4716 # can't write to a scalar
File ~/opt/anaconda3/envs/Hyperspy/lib/python3.9/site-packages/numpy/lib/function_base.py:4527, in _lerp(a, b, t, out)
4513 def _lerp(a, b, t, out=None):
4514 """
4515 Compute the linear interpolation weighted by gamma on each point of
4516 two same shape array.
(...)
4525 Output array.
4526 """
-> 4527 diff_b_a = subtract(b, a)
4528 # asanyarray is a stop-gap until gh-13105
4529 lerp_interpolation = asanyarray(add(a, diff_b_a * t, out=out))
TypeError: numpy boolean subtract, the -
operator, is not supported, use the bitwise_xor, the ^
operator, or the logical_xor function instead."
Checking the type of c and cs returns a value of false for float. How may I fix this issue? The notebook is public in my repository
Thanks again