Skip to content

Fix TypeError with empty axes in FFT functions#288

Open
antonwolfy wants to merge 3 commits intomasterfrom
fix-error-on-empty-axes
Open

Fix TypeError with empty axes in FFT functions#288
antonwolfy wants to merge 3 commits intomasterfrom
fix-error-on-empty-axes

Conversation

@antonwolfy
Copy link
Collaborator

@antonwolfy antonwolfy commented Mar 12, 2026

This PR fixes "copyto() argument 1 must be a numpy.ndarray" error, like:

deploy/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/lib/python3.13/site-packages/mkl_fft/_fft_utils.py", line 250, in _iter_complementary
    np.copyto(result[tuple(sl)], func(x[tuple(sl)], **kwargs))
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: copyto() argument 1 must be a numpy.ndarray, not numpy.complex128

when calling FFT functions with axes=().

Thus the PR adds a fast path to handle empty axes as identity transform, matching NumPy behavior.

The issue was introduced in scope of #283. The tests coverage is improved.

@antonwolfy antonwolfy added this to the 2.2.0 release milestone Mar 12, 2026
@antonwolfy antonwolfy self-assigned this Mar 12, 2026
@antonwolfy antonwolfy marked this pull request as ready for review March 12, 2026 18:02
Copy link
Contributor

@jharlow-intel jharlow-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linux validation failure is due to bdba server outage, nothing to do with this PR.

LGTM, thanks for adding the new test cases, too

direction=+1,
scale_function=lambda ind: 1.0,
):
a = np.asarray(a)
Copy link
Collaborator

@ndgrigorian ndgrigorian Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent a bit of time trying to figure out the cause of this change, eventually it made sense, but I realized that it would be easier if these functions in this file were better documented...

It's not in the scope of this PR to fix all of them, but would you mind adding one to this function? @antonwolfy in particular mentioning now that a is expected to be numpy array

Copy link
Collaborator

@ndgrigorian ndgrigorian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than previous comment LGTM

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.

3 participants