Skip to content

irfftn corrupts input when dimensions >=3 #4

Closed
@rainwoodman

Description

@rainwoodman

Originally posted as numpy/numpy#10895

Seems to be introduced recently. It doesn't affect fftn, ifftn or rfft, irfft.

Here is the reproducer.

import numpy
from numpy.testing import assert_allclose

def showbug(nd):
    size = [4] * nd
    x = numpy.random.uniform(size=size)
    y = numpy.fft.rfftn(x)
    y1 = y.copy()

    numpy.fft.irfftn(y1)

    assert_allclose(y1, y)

showbug(3)
Traceback (most recent call last):
  File "fftbug.py", line 14, in <module>
    showbug(3)
  File "fftbug.py", line 12, in showbug
    assert_allclose(y1, y)
  File "/home/yfeng1/anaconda3/install/lib/python3.6/site-packages/numpy/testing/utils.py", line 1395, in assert_allclose
    verbose=verbose, header=header, equal_nan=equal_nan)
  File "/home/yfeng1/anaconda3/install/lib/python3.6/site-packages/numpy/testing/utils.py", line 778, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=1e-07, atol=0

(mismatch 100.0%)
 x: array([[[ 1.612765+0.j      , -0.069468+0.278309j, -1.196650+0.j      ],
        [ 1.794408+0.j      ,  0.084526+0.187052j,  0.642339+0.j      ],
        [ 1.536380+0.j      , -0.811544-0.006539j,  0.736002+0.j      ],...
 y: array([[[  3.227387e+01+0.j      ,  -6.852522e-01-0.432786j,
          -2.638166e+00+0.j      ],
        [ -9.017300e-01+2.401103j,   1.732144e+00+0.885346j,...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions