| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Closes matplotlib#28780. The underlying problem is that operations on numpy scalars try to eagerly convert the other operand to an array. As a result `scalar = np .float64 (2); scalar * radians` would result in a numpy scalar. But we don't want that. Instead we enforce `radians.__rmul__(scalar)` by giving the unit a higher `__array_priority__`. See also https://github .com/numpy/numpy/issues/17650. I haven't found any specific change notes on this in numpy 2.1. Interestingly, the full story is even more complex. Also for numpy<2.1 `radians.__rmul__(scalar)` is not called, but there seems another mechanism through __array__ and __array_warp__ catching back in so that the result is again a TaggedValue. But I have not fully investigated why it worked previously. In fact, we want the solution here with going through __rmul__, and that works for all numpy versions. `
There was a problem hiding this comment.
but also will follow up on discussion in issue about this example
Sorry, something went wrong.
|
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
git checkout v3.10.x git pull
git cherry-pick -x -m1 3fa730d807f823baa27177a1a499cd7e293537fb
git commit -am 'Backport PR #29616: FIX: Fix unit example so that we can unpin numpy<2.1'
git push YOURFORK v3.10.x:auto-backport-of-pr-29616-on-v3.10.x
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the Still Needs Manual Backport label once the PR gets merged. If these instructions are inaccurate, feel free to suggest an improvement. |
Sorry, something went wrong.
|
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
git checkout v3.10.0-doc git pull
git cherry-pick -x -m1 3fa730d807f823baa27177a1a499cd7e293537fb
git commit -am 'Backport PR #29616: FIX: Fix unit example so that we can unpin numpy<2.1'
git push YOURFORK v3.10.0-doc:auto-backport-of-pr-29616-on-v3.10.0-doc
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the Still Needs Manual Backport label once the PR gets merged. If these instructions are inaccurate, feel free to suggest an improvement. |
Sorry, something went wrong.
|
Don't see any point of backporting to the doc branch if 3.10.1 is imminent. |
Sorry, something went wrong.
…3.10.x Backport PR #29616 on branch v3.10.x (FIX: Fix unit example so that we can unpin numpy<2.1)
|
It's not urgent but somehow these changes should propagate to the doc branch. How does it work? Is doc reset to 3.10.x when that is released or is 3.10.x merged into doc? |
Sorry, something went wrong.
|
It's merged together before a release, and v3.10.1-doc starts fresh after v3.10.1 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #28780.
The underlying problem is that operations on numpy scalars try to eagerly convert the other operand to an array. As a result scalar = np .float64(2); scalar * radians would result in a numpy scalar. But we don't want that.
Instead we enforce radians.__rmul__(scalar) by giving the unit a higher __array_priority__. See also numpy/numpy#17650.
I haven't found any specific change notes on this in numpy 2.1. Interestingly, the full story is even more complex. Also for numpy<2.1 radians.__rmul__(scalar) is not called, but there seems another mechanism through __array__ and __array_warp__ catching back in so that the result is again a TaggedValue. But I have not fully investigated why it worked previously. In fact, we want the solution here with going through __rmul__, and that works for all numpy versions.