cokelaer/spectrum

scipy fftn produces warning that numpy fftn does not

Closed this issue · 3 comments

When working on addressing the deprecation warning announced in #49 , I found that the scipy.fftpack.fftn produces a different warning:

import numpy as np
from scipy.fftpack import fftn
a = np.random.random([16,16])
fftn(a, [32,32])      

/home/apn/proj/spectrum/lib/python3.6/site-packages/scipy-1.1.0-py3.6-linux-x86_64.egg/scipy/fftpack/basic.py:160: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.
z[index] = x

If you use the numpy version of fftn, this warning goes away, and the answers are the same:

np.allclose(np.fft.fftn(a,[32,32]) , fftn(a, [32,32]))

is True

I'm not sure if there's a reason to choose one of the fftn over another, but the warning appears to come from scipy and could be removed by switching to the numpy version.

I'm suing scipy 1.1.0, numpy 1.15.2 and python 3.6.5

Thanks for reporting this warning. For book-keeping, not seen with python 3.5.5, scipy 1.0 and numpy 1.14.1 does not show this warning. Interesting to see that fft version from numpy is without warning. I'm keeping this issue open for now.

It turns out that scipy and numpy use different code to implement their ffts. There's some explanation here that his helpful.
https://stackoverflow.com/questions/6363154/what-is-the-difference-between-numpy-fft-and-scipy-fftpack

I have not thought too much about which is better in this case.

no more warnings with current version of python (3.7.3) and latest scipy/numpy version.
closing for now