[SciPy-user] Numpy/Scipy rfft transformations do not match?

Jeffery Kline jeffery.kline@gmail....
Mon Jun 15 14:35:38 CDT 2009

This is from an old thread about rfft versions in numpy and scipy.

I'm writing in support of numpy's rfft output format.

In my application, I am interested in the real portion of the rfft of
a n-dimensional array. With numpy.rfft, the syntax is elegant:

X=npfft.rfft(X, axis=j).real

With scipy.rfft, the syntax is more complicated. It requires something like

X=spfft.rfft(X, axis=j).take(index,axis=j)

Occasionally, for debugging/testing, I recreate the full spectrum with
the resulting output from rfft. To do this with numpy's rfft is
natural and easy to read.  The corresponding code with scipy's rfft
output is more involved.

Similar statements hold with respect to the corresponding irfft functions.

Finally, speed is an issue for me. I currently have no benefit to
using scipy over numpy -- scipy's rfft returns somewhat faster for me,
but after collecting the array elements I need, the cost is larger in
time.  Possibly for sufficiently large arrays, I will see a benefit,
but the cost in code development is not currently worth it for me.

More information about the SciPy-user mailing list