-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Minor fix for astropy units support broken in earlier PR #23141
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
I think it needs a test, or we can break again. Unless you think the Quantities behaviour is a bug, in which case we should bounce the issue back to them. |
Well, the "bug" is that This was not clear from the documentation. So any use of Not sure how to modify our Here is a simple example to show the problem:
So we would like our |
Let me rephrase that: any use of There is only one use of that, apart from this, namely in |
OK, this is fine. However, my complaint stands that this should be dealt with earlier than this in the processing of the inputs so that we don't keep having to squash issues like this. |
I dug a bit more into it and astropy Redefining I do not disagree that units should be handled differently. Just that I have very limited insight into it. It would indeed make sense to get our mock |
I am going to cc @mhvk here too in case he has insights. Thanks! |
I'll only add that the Instead of changing it, I'd advise making a different mock for astropy, and possibly make the tests parameterized around the mocks. |
Thanks for the info @dopplershift ! I can confirm that
shows that the results of So something is slightly different for |
Pretty sure by design |
I agree. Thought it was a convenience method for getting the same shape, not subclass, hence the introduced problem. I'll try and make a second |
Nah, it is possible to subclass (by getting rid of I, again, suggest that we should instead extend the weekly upcoming dependency tests So I think that this is good to go as is. |
Maybe pint is light weight enough to add as a test requirement for unit tests. |
pint is 300 k, so should not be a problem. astropy (which causes the issue here) is 6-7 MB, so probably not worth it. |
According to the above, pint and astropy are basically the same wrt the Quantity class? |
AFAIK they are unrelated? |
Oh I'm sorry I misunderstood @dopplershift OTOH we should check the blame. |
If it is my statements you are referring to, I must have been unclear. However, I think I now have a much briefer summary:
|
Indeed, astropy's |
The job that was failing with matplotlib dev now passes over at |
PR Summary
See #22929 (comment)
This is not possible to test without importing
astropy
, but if I only had selected this approach first, no one would have objected. (OurQuantity
-mock class does not show this problematic behavior.)Thanks @greglucas for suggesting the very simple solution (simple enough so that I didn't believe it would solve it...).
For a description of why the earlier approach using
zeros_like
didn't work see numpy/numpy#21603PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).