Skip to content
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

Fixes NumPy interface bug which did not allow for list/ndarray axes or s parameters #69

Merged
merged 3 commits into from
Aug 18, 2022

Conversation

cako
Copy link
Contributor

@cako cako commented May 14, 2022

Description

NumPy multidimensional FFTs accept tuple, list and np.ndarray for the axes and s parameters. Upon substituting a code which ran on standard numpy for one running on intel-numpy, I came across a bug where axes and s struggled to handle anything apart from tuple.

This came down to a couple of bugs in mkl_fft which are fixed in this PR. In addition, I added a test which should catch these bugs in the future.

Edit: Commit 75e9ffd is unrelated to the bug. It's just a code improvement.

Reproducible examples

To simplify checking, here is a list of behaviors which work/do not work currently. This PR fixes them.

import numpy as np

np.fft.fftn(np.ones((2, 3, 4)), axes=(-1, 0))  # Works
np.fft.fftn(np.ones((2, 3, 4)), axes=[-1, 0])  # Does not work
np.fft.fftn(np.ones((2, 3, 4)), axes=np.array([-1, 0]))  # Does not work
np.fft.fftn(np.ones((2, 3, 4)), axes=(-1, 0), norm="ortho")  # Works
np.fft.fftn(np.ones((2, 3, 4)), axes=[-1, 0], norm="ortho")  # Does not work
np.fft.fftn(np.ones((2, 3, 4)), axes=np.array([-1, 0]), norm="ortho")  # Does not work

np.fft.fftn(np.ones((2, 3, 4)), s=(3, 4, 5))  # Works
np.fft.fftn(np.ones((2, 3, 4)), s=[3, 4, 5])  # Works
np.fft.fftn(np.ones((2, 3, 4)), s=np.array([3, 4, 5]))  # Works

np.fft.fftn(np.ones((2, 3, 4)), s=(4, 5), axes=(-1, 0))  # Works
np.fft.fftn(np.ones((2, 3, 4)), s=[4, 5], axes=[-1, 0])  # Works
np.fft.fftn(np.ones((2, 3, 4)), s=np.array([4, 5]), axes=np.array([-1, 0]))  # Works
np.fft.fftn(np.ones((2, 3, 4)), s=np.array([4, 5]), axes=np.array([-1, 0]), norm="ortho")  # Does not work

cako added 3 commits May 14, 2022 13:24
* NumPy fftnd support for list and ndarray for `axes`
* NumPy fftnd support for list and ndarray for `s` when `norm="ortho"`
@oleksandr-pavlyk oleksandr-pavlyk merged commit a25a98f into IntelPython:master Aug 18, 2022
@oleksandr-pavlyk
Copy link
Collaborator

Thanks you @cako

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 this pull request may close these issues.

None yet

2 participants