Python 在SciPy中调用convolve2d()时出现ComplexWarning,为什么?

Python 在SciPy中调用convolve2d()时出现ComplexWarning,为什么?,python,scipy,convolution,Python,Scipy,Convolution,当我跑的时候 from scipy.signal import convolve2d convolve2d([[2, 2, 2], [1, 2, 3], [0, 1, 0]], [[0.5], [0.5]], 'valid') 我明白了 为什么会出现这种情况,以及如何正确防止这种情况?这是一个在0.12.0版中修复的错误。您使用的是哪个版本的scipy?我在使用scipy 0.11.0时收到警告,但在运行根据最新源代码构建的scipy时没有收到警告,因此显然这已经得到修复。@WarrenWec

当我跑的时候

from scipy.signal import convolve2d
convolve2d([[2, 2, 2], [1, 2, 3], [0, 1, 0]], [[0.5], [0.5]], 'valid')
我明白了


为什么会出现这种情况,以及如何正确防止这种情况?

这是一个在0.12.0版中修复的错误。

您使用的是哪个版本的scipy?我在使用scipy 0.11.0时收到警告,但在运行根据最新源代码构建的scipy时没有收到警告,因此显然这已经得到修复。@WarrenWeckesser:啊,我也在使用0.11.0。。。那我就试试0.12,谢谢你让我知道。我刚试过0.12.0(这是最新的版本),但我没有收到警告。@WarrenWeckesser:太棒了,请随意发布它作为答案!:)由于某些原因,
scipy.signal.sigtools.\u convolve2d
中仍然存在错误,如果是直接调用(没有
scipy.signal.convolve2d
)。。。有人知道原因吗?我使用scipy0.15.0
Warning (from warnings module):
  File "C:\Program Files\Python 2.7\lib\site-packages\scipy\signal\signaltools.py", line 422
    return sigtools._convolve2d(in1, in2, 1, val, bval, fillvalue)
ComplexWarning: Casting complex values to real discards the imaginary part