[Numpy-discussion] numpy.fft.irfftn fails apparently unexpectedly

Henry Gomersall heng at cantab.net
Mon Feb 6 13:32:09 EST 2012


Is the following behaviour expected:

>>> import numpy
>>> a_shape = (63, 4, 98)
>>> a = numpy.complex128(numpy.random.rand(*a_shape)+\
...     1j*numpy.random.rand(*a_shape))
>>> 
>>> axes = [0, 2]
>>> 
>>> numpy.fft.irfftn(a, axes=axes)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.7/numpy/fft/fftpack.py", line 1080,
in irfftn
    s, axes = _cook_nd_args(a, s, axes, invreal=1)
  File "/usr/lib/pymodules/python2.7/numpy/fft/fftpack.py", line 515, in
_cook_nd_args
    s[axes[-1]] = (s[axes[-1]] - 1) * 2
IndexError: list index out of range

The implication from the docs is that axes can be arbitrary. The
following *does* work fine:

>>> import numpy
>>> a = numpy.float64(numpy.random.rand(*a_shape))
>>> axes = [0, 2]
>>> numpy.fft.rfftn(a, axes=axes)


Thanks,

Henry




More information about the NumPy-Discussion mailing list