-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MNT: avoid future incompatibility with numpy 1.25 (casting single element arrays to scalar types) #25745
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
…ment arrays to scalar types)
I ran the test suite locally with bleeding edge numpy installed + |
It would seem like the spirit of numpy's deprecation is more that we should also move towards not supporting passing single-element arrays here... |
Should I throw a deprecation warning in for that case ? |
Why would someone pass in a single element array here anyhow? Can we not just let numpys warning suffice? |
for context, I'm not advocating that this is a reasonable use case. I've discovered this because it was triggered by the following line in yt : If you guys are not interested in patching it in matplotlib, feel free to just close this alongside the issue I opened. |
I think we are just trying to understand the issue to help decide the best way forward. Why, in the linked code, would The ways forward are 1) work around this silently, 2) Deprecate on our end 3) just let the numpy Deprecation stand. I agree with @anntzer that we should do 2 or 3. I'd suggest we only do 2 if we think there is a reasonable use case where folks would have done this. |
I am 👎🏻 on taking this patch. I think that single element arrays (as opposed to 0-d "arrays") ever worked in this context is an accident of numpy's implementation. I agree with @jklymak that in the yt example something else is funny. From the names my guess is that the |
good point. What's happening is that and even though Again, no worries if you guys want to discard this as out of scope. :-) |
I'm going to decline this PR. As I said above, that this ever worked was an accident and we should trust Numpy's judgement that this is a behavior change we want. The right place for this to be fixed is in the call site passing this to us (either user code or other down-stream libraries). Thank you for bringing this up @neutrinoceros . I normally say "we hope to hear from you again", but when we hear from you it is likely because we broke yt and I hope we do not do that ;) |
PR Summary
fix the one issue in #25744 that I know how to reproduce. There might be more (I'll open this for review after I'm done discovering and fixing them).
I'm not sure how to document this kind of change for release notes, I'd appreciate guidance there.
PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst