ValueError:至少需要堆叠一个数组

时间:2019-08-18 20:45:21

标签: python pycharm jupyter

我正在使用Hyperspy官方网站上的代码在图像堆栈上测试高斯滤波器。我不断收到错误消息“ ValueError:至少需要堆叠一个数组”。

%matplotlib qt

import hyperspy.api as hs
import numpy as np
import scipy.ndimage

im = hs.signals.Signal2D(np.random.random((10, 64, 64)))
im.map(scipy.ndimage.gaussian_filter, sigma=2.5)

ValueError:至少需要堆叠一个数组

跟踪信息     -------------------------------------------------- -------------------------

ValueError                                Traceback (most recent call last)

<ipython-input-2-37abd5454503> in <module>
      1 im = hs.signals.Signal2D(np.random.random((10, 64, 64)))
----> 2 im.map(scipy.ndimage.gaussian_filter, sigma=2.5)
      3 

f:\programming\python\projects\hyperspy\lib\site-packages\hyperspy\signal.py in map(self, function, show_progressbar, parallel, inplace, ragged, **kwargs)
   3931                                     parallel=parallel, inplace=inplace,
   3932                                     ragged=ragged,
-> 3933                                     **kwargs)
   3934         if inplace:
   3935             self.events.data_changed.trigger(obj=self)

f:\programming\python\projects\hyperspy\lib\site-packages\hyperspy\signal.py in _map_iterate(self, function, iterating_kwargs, show_progressbar, parallel, ragged, inplace, **kwargs)
   4076         if not ragged:
   4077             sig_shape = () if shapes[0] == (1,) else shapes[0]
-> 4078             res_data = np.stack(res_data.flat).reshape(
   4079                 self.axes_manager._navigation_shape_in_array + sig_shape)
   4080         res = map_result_construction(self, inplace, res_data, ragged,

<__array_function__ internals> in stack(*args, **kwargs)

f:\programming\python\projects\hyperspy\lib\site-packages\numpy\core\shape_base.py in stack(arrays, axis, out)
    419     arrays = [asanyarray(arr) for arr in arrays]
    420     if not arrays:
--> 421         raise ValueError('need at least one array to stack')
    422 
    423     shapes = {arr.shape for arr in arrays}

ValueError: need at least one array to stack

0 个答案:

没有答案