scipy 中的 fftshift 是否损坏?
我使用最新版本的 numpy/scipy。
以下脚本不起作用:
import numpy as np
import matplotlib.pyplot as plt
from scipy.fftpack import fft, fftshift, fftfreq
hn= np.ones(10)
hF = fft(hn,1024)
shifted = fftshift(hF)
它给出以下错误消息:
Traceback (most recent call last):
File "D:\deleteme\New3.py", line 6, in <module>
shifted = fftshift(hF)
File "C:\Python26\lib\site-packages\numpy\fft\helper.py", line 40, in fftshift
y = take(y,mylist,k)
File "C:\Python26\lib\site-packages\numpy\core\fromnumeric.py", line 103, in take
return take(indices, axis, out, mode)
TypeError: array cannot be safely cast to required type
编辑:我发现了问题。我的 python 解释器是通过 -Qnew 选项隐式调用的(通过我的编辑器设置)。这显然破坏了 scipy 代码。 感谢所有回复的人!
I use the latest version of numpy/scipy.
The following script does not work:
import numpy as np
import matplotlib.pyplot as plt
from scipy.fftpack import fft, fftshift, fftfreq
hn= np.ones(10)
hF = fft(hn,1024)
shifted = fftshift(hF)
It gives the following error message:
Traceback (most recent call last):
File "D:\deleteme\New3.py", line 6, in <module>
shifted = fftshift(hF)
File "C:\Python26\lib\site-packages\numpy\fft\helper.py", line 40, in fftshift
y = take(y,mylist,k)
File "C:\Python26\lib\site-packages\numpy\core\fromnumeric.py", line 103, in take
return take(indices, axis, out, mode)
TypeError: array cannot be safely cast to required type
EDIT: i have found the problem. My python interpreter was implicitly called (via my editor settings) with the -Qnew option. This apparently breaks scipy code.
Thanks to all who responded!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该在 http://www.scipy.org/BugReport 上填写错误报告
You should fill in a bug report on http://www.scipy.org/BugReport
与我的设置配合良好,如果当前版本中存在错误,请尝试安装旧版本并填写报告。
Works fine with my setup, if it's a bug in the current version try installing an older copy and filling out a report.