[SciPy-dev] fftpack revisited

Pearu Peterson pearu at cens.ioc.ee
Mon Aug 19 02:02:36 CDT 2002

On Mon, 19 Aug 2002, Pearu Peterson wrote:

> There is only one thing in the interface that I would like to discuss. For
> example, fftpack.fft has three arguments:
>   fft(a, n=None, axis=-1)
> The second argument n stands for the size of the Fourier transform
> (matrix). It seems to me that this argument could be dropped as this
> information already is contained in a.shape and axis:
>   n = a.shape[axis]
> In fftpack._raw_fft this is a special case and, in general, the following
> rules are applied: 
> *  If n>a.shape[axis] then a is padded with zeros.
> *  If n<a.shape[axis] then a is trunctated. 
> Both cases create a new array that is non-contiguous (except in
> special cases). So, in total there will be two copies made of input data
> before passing it to Fortran. 
> I wonder if we could move this functionality out from the fft functions?
> I think that the padding functionality is already covered by the
> fftpack.zeropad function and truncating can be done by slicing.

Another point of removing this feature is that it is easy to produce hard
to find bugs. For instance, fft always succeeds whatever is the value of
integer n. If one uses a value that is not correct, then calculations
either succeed with totally incorrect results or fail far from calling
fft. Debugging such cases can be difficult as it is not obvious what will
happen by just reading the code.

Just another thought...


More information about the Scipy-dev mailing list