【问题标题】:Is the fact that scipy.fft links to numpy.fft.fftpack.fft documented anywhere?scipy.fft 链接到 numpy.fft.fftpack.fft 的事实是否记录在任何地方?
【发布时间】:2017-11-24 21:25:03
【问题描述】:

我找不到任何官方文档说明scipy.fft 实际上是指向numpy.fft.fftpack.fft 的链接。这是一个显示链接的 iPython 会话:

In [1]: import scipy

In [2]: import numpy

In [3]: scipy.__version__
Out[3]: '0.19.0'

In [4]: numpy.__version__
Out[4]: '1.12.1'

In [5]: scipy.fft
Out[5]: <function numpy.fft.fftpack.fft>

我能找到的关于scipy.fft 子模块的唯一提及是this discussion on numpy-discussionthis discussion on SciPy's Github,这两者似乎都暗示了当时实际上并不存在这样的子模块。

【问题讨论】:

  • 您为什么对此感兴趣?那不是只需要在源代码中记录的实现细节吗?
  • 这样的东西到处都是。哎呀,我认为scipy.fft 的名称根本没有记录在案。
  • 这是scipy 命名空间的一个不幸的怪癖。它包含 所有 个 numpy 名称(例如 scipy.arrayscipy.linspace 等)。不鼓励使用这些名称;使用 numpy 命名空间更清晰。

标签: python numpy scipy fft


【解决方案1】:

是的,是documented

从 Scipy 导入函数的指南

scipy 命名空间本身只包含从 numpy 导入的函数。为了向后兼容,这些函数仍然存在,但应该直接从 numpy 导入。

[...]

【讨论】:

  • 仅供参考(其中“Y”是“y'all's”,而不仅仅是 MSeifert's):顶级 scipy 命名空间中有用的一件事是 scipy.__version__
【解决方案2】:

scipy.__init__.py 文件有:

from numpy import *
from numpy.random import rand, randn
from numpy.fft import fft, ifft
from numpy.lib.scimath import *

__all__ += _num.__all__
__all__ += ['randn', 'rand', 'fft', 'ifft']

【讨论】:

    猜你喜欢
    • 2014-04-18
    • 1970-01-01
    • 2012-12-03
    • 1970-01-01
    • 2021-08-26
    • 1970-01-01
    • 2021-02-16
    • 2016-08-17
    • 2021-12-12
    相关资源
    最近更新 更多