Skip to content

Incorrect fft tests #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
asmeurer opened this issue Jan 23, 2024 · 1 comment · Fixed by #233
Closed

Incorrect fft tests #231

asmeurer opened this issue Jan 23, 2024 · 1 comment · Fixed by #233

Comments

@asmeurer
Copy link
Member

Some fft tests need to be updated from data-apis/array-api#720

Here's the current fft test failures for array_api_strict:

FAILED array_api_tests/test_fft.py::test_fft - TypeError: Only complex floating-point dtypes are allowed in fft
FAILED array_api_tests/test_fft.py::test_ifft - TypeError: Only complex floating-point dtypes are allowed in ifft
FAILED array_api_tests/test_fft.py::test_fftn - TypeError: Only complex floating-point dtypes are allowed in fftn
FAILED array_api_tests/test_fft.py::test_ifftn - TypeError: Only complex floating-point dtypes are allowed in ifftn
FAILED array_api_tests/test_fft.py::test_rfft - AssertionError: out.shape=(2,), but should be (3,) [rfft()]
FAILED array_api_tests/test_fft.py::test_irfft - AssertionError: out.dtype=float32, but should be complex64 [irfft(complex64)]
FAILED array_api_tests/test_fft.py::test_rfftn - AssertionError: out.shape=(2,), but should be (3,) [rfftn()]
FAILED array_api_tests/test_fft.py::test_irfftn - AssertionError: out.dtype=float32, but should be complex64 [irfftn(complex64)]
FAILED array_api_tests/test_fft.py::test_hfft - ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
FAILED array_api_tests/test_fft.py::test_ihfft - AssertionError: out.shape=(2,), but should be (4,) [ihfft()]

Some of the tests are still using real inputs for functions that are changed to only require complex.

The dtype checks in irfft and irfftn are also wrong. Those functions map complex -> real.

Finally, the shape checks seem to be wrong. The PR updates what the output shape should be for ihfft. The test expects an input shape of 3 to map to 4, but the output shape should be 2 == 3//2 + 1.

The rfftn and rfft shape tests are matching what the spec says, but I think that might also be wrong (or at least NumPy's implementation and documentation disagrees). See https://github.com/data-apis/array-api/pull/720/files#r1463962541 and https://github.com/data-apis/array-api/pull/720/files#r1463964686

As far as I can tell, the array_api_strict/np.array_api implementation should be correct here, although someone will need to confirm whether the spec needs to be updated for rfft and rfftn.

@asmeurer
Copy link
Member Author

Setting axes to None if s is not None will probably also be disallowed #230

@honno honno mentioned this issue Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant