-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
API: adjust nD fft s
param to array API
#25495
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
Conversation
If we want to do this, it needs a release note. It should likely also be mentioned in the array API compat notes in the docs. Also it sounds like the array API tests don't cover this unless our test suite has an exception for it already. I searched a little and found one real-world usage this would break in a hydrodynamics solver: https://github.com/pencil-code/pencil-code/blob/91ad3991c339fa62cdf5546cea64fac854c2ba9f/python/pencil/math/Helmholtz.py#L99 Perhaps this could be a deprecation? |
https://github.com/numpy/numpy/blob/main/tools/ci/array-api-skips.txt#L36-L37 Apparently the
I thought the point was to use 2.0 to make the necessary breaking changes for ~100% compat, but forgive me if I'm out of the loop.
Happy to add these if we want to continue here. |
Also, I didn't look thoroughly at whether these functions need any other changes. If it turns out that you are going to be touching these functions anyway @mtsokol, feel free to take over my PR. I thought this might have just been something which was missed, which would be understandable considering the buggy tests. |
From community meeting, to-do here:
|
What should the deprecation messages say? Mark for removal in 2 release cycles or...? |
The warning should describe the behavior that's deprecated (e.g. "specifying the s parameter without also specifying the axes parameter is deprecated") and suggest an alternative that isn't deprecated if that's possible. You should also leave a comment next to the deprecation saying when it happened and which numpy version it's in. A few numpy deprecations list a specific version the deprecation will expire but it leaves a little more flexibility if you don't specify it. Also make sure the stacklevel is correct given where in the call stack the warning comes from. An example I found via grep:
|
Please make sure to add when the warning was added, like |
To be deprecated: "If
New features: "If
|
Looks like CI is happy, ready for a look @ngoldbaum ! |
`numpy.fft.fftn`, `numpy.fft.ifftn`, `numpy.fft.rfftn` and `numpy.fft.irfftn` | ||
are deprecated in line with the following part of the array API | ||
specification: "If ``s`` is not ``None``, ``axes`` must not be ``None``". |
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.
Suggested wording change to the above:
Using `numpy.fft.fftn`, `numpy.fft.ifftn`, `numpy.fft.rfftn` and `numpy.fft.irfftn` with the ``s`` parameter set to value that is not `None` and the ``axes`` set to ``None`` has been deprecated, to match the array API standard.
Right now a reader might mistakenly read that the whole function is deprecated, not just this one usage.
If a user has s
set to None
or passes an array containing None
, what should they do now to get the same behavior back?
EDIT: Ah, I see you mention the fix in the warning, just need to also mention it here.
I've updated the release notes for your suggestion and also documented the deprecations for |
@pytest.mark.parametrize("op", [np.fft.fftn, np.fft.ifftn, | ||
np.fft.fft2, np.fft.ifft2]) | ||
def test_s_negative_1(self, op): |
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.
real transforms aren't included since the shapes aren't the same
s
param to array APIs
param to array API
Thanks @lucascolley! |
thanks for the review Nathan and Marten! |
Towards gh-25076, closes gh-14179, closes scipy/scipy#10569
scipy/scipy#10569 reported that the
s
parameter of NumPy's nD fft functions behaves differently to the equivalent inscipy.fft
. I checked, and there are some changes needed for array API compatibility. This PR adjusts for the following lines of the spec:To be deprecated:
"If s is not None, axes must not be None."
s and axes should be of type Sequence[Int]
Current behaviour:
numpy.fft: Undocumented behavior of
s
argument #14179New features:
"If s[i] is -1, the whole input array along the axis i is used (no padding/trimming)."