-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH: Add numpy.shifted. #29389
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
base: main
Are you sure you want to change the base?
ENH: Add numpy.shifted. #29389
Conversation
1b26c2c
to
44b4dc9
Compare
Thank you! As this is a new feature that adds to our API surface, we do ask that you discuss this on the mailing list first. In the issue that you linked, I don't think any numpy maintainer actually participated in the discussion. We are quite conservative in which functions that we add to the main numpy namespace. We like to coordinate with the Array API Standard especially since there are other similar implementations around like Pandas'. You might do better to propose an addition to the Array API, which will get the attention and input from other array implementors as well. |
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.
It should also go in the __all__
in __init__.py
and __init__.pyi
@jorenham Done. So many places to keep track of. 😅 I wonder if that could be improved. (Cutting down the number of places that each function needs to be declared in, reducing the size of the codebase and making it easier to edit.) |
I spend most of my time writing stubs, so I've given up on my DRY dreams haha. But there are some tools that usually help spot these kind of errors, e.g. ruff complaining about unused imports, or stubtest reporting that the |
I think in principle having the option to shift rather than roll is nice to have, and fairly frequently used. I wonder, though, if a standalone function is the best way forward. Two alternatives,
Note that even if we don't go with either of the above, we should not have so much code duplication between p.s. If we do go with a new function (not sure we should!), I'd prefer to just call it |
Thanks for your comments.
I disagree with this bit specifically. I think users should be able to set a behavior by changing a value, not just by omitting it.
That would take up extra memory, especially when
I also prefer I could rename the Also open to other suggestions. |
Why would it take more memory? You're creating a new array here too, and passing a shortened view to |
Nevermind. I see what you meant. |
Fixes #26220.