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
BUG: Fix rfft for even input length. #26354
Conversation
mac failure is an unrelated heisenbug |
numpy/fft/tests/test_pocketfft.py
Outdated
def test_rfft_even(self): | ||
x = np.arange(8) | ||
y = np.fft.rfft(x, 4) | ||
assert_allclose(y, [6.0, -2.0+2.0j, -2.0], rtol=1e-14) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use the same sort of test as for the odd case, I like comparing to the full complex fft case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Thanks Warren. |
@@ -183,12 +183,15 @@ rfft_impl(char **args, npy_intp const *dimensions, npy_intp const *steps, | |||
* Pocketfft uses FFTpack order, R0,R1,I1,...Rn-1,In-1,Rn[,In] (last | |||
* for npts odd only). To make unpacking easy, we place the real data | |||
* offset by one in the buffer, so that we just have to move R0 and | |||
* create I0=0. Note that copy_data will zero the In component for | |||
* create I0=0. Note that copy_input will zero the In component for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird - so, the statement I made in the comment is not true? I'll try to have a quick look, but in any case the fix clearly works.
#26359 does a follow-up that ensures the code actually does what the comment states. Would be nice to have both this one and #26359 be in 2.0.0.... Must admit that overall rewriting the fft routines in terms of ufuncs has been more of an experience in how hard it is to write bug-free code than I would have liked... Sorry all! |
Closes gh-26349