-
-
Notifications
You must be signed in to change notification settings - Fork 5
Narrow the return types of the functions in fft._helper
#339
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
Comments
Not sure if it's worth a separate issue, but I think I see a typo in what I think is the test: in I saw it because I thought I would take a look at this as something possibly within my grasp I could help with, but I fear I may be in over my head. It looks like the stubs for fftfreq are accepting an ArrayLike (and the tests supply an ndarray) for the 'd' parameter, when the documentation clearly states it's a scalar. Is that an implementation detail or a typo? Everywhere else in that module the ArrayLike is used appropriately. If it's a typo I could take a stab at fixing. |
Good catch! A PR for this is certainly welcome welcome :)
Yea I took a look, and it's indeed not as easy as it looks. Array-like's are notoriously difficult to properly type, and in this case, there's also shape-typing involved. I'll work on this soon, and will ping you once I have the PR ready, in case you're interested.
Yea the documentation is not the whole truth in this case. Because in practice it'll work with anything that's broadcastable with a 1d array of shape >>> import numpy as np
>>> np.fft.fftfreq(4, np.linspace(.1, .2, 8).reshape(2, 4))
array([[ 0. , 2.1875 , -3.88888889, -1.75 ],
[ 0. , 1.45833333, -2.69230769, -1.25 ]]) So if |
Ah, I thought it might be something like that. I will leave it to you then because I definitely don't know the code well enough heh. I can fix the test typo though! |
I made PR #346 for the typo :-) |
Please describe the feature or change you would like to see:
The current return types are annoying broad, which could lead to issues with external library function signatures with too narrow input types, like
matplotlib
.This was originally pointed out by @Jeitan in numpy/numpy#28076 (comment)
The text was updated successfully, but these errors were encountered: