scipy/legacy-fftpack
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| SciPy | info | unsafe, with xpd check --fix --unsafe-fixes |
All versions |
scipy.fftpack is legacy, and SciPy says new code should use scipy.fft. Import from scipy.fft, and check rfft, whose output layout differs.
from scipy import fftpacky = fftpack.dct(x)from scipy import ffty = fft.dct(x)What the rule reports
Section titled “What the rule reports”The rule reports an import of scipy.fftpack, whose module docstring marks it as legacy and
says new code should use scipy.fft. scipy.fft was no faster in the measurements, so the rule
claims only the preference.
How to fix it
Section titled “How to fix it”xpd check --fix --unsafe-fixes rewrites from scipy.fftpack import ... to from scipy.fft import ... when every imported name has a compatible scipy.fft equivalent (excluding rfft, irfft, rfftfreq, and pseudo-differential operators). Other imports remain manual.
The real FFT functions of fftpack and scipy.fft pack the result differently. Operators such as diff and tilbert have no equivalent in scipy.fft.
Diagnostic message
Section titled “Diagnostic message”scipy.fftpack is legacy, and its SciPy docstring says new code should use scipy.fft. Import from scipy.fft instead, and check rfft, whose output layout differs.See all rules in the SciPy pack.