Skip to content

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 fftpack
y = fftpack.dct(x)
from scipy import fft
y = fft.dct(x)

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.

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.

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.