Title: FIX: Fix unit example so that we can unpin numpy<2.1 by timhoffm · Pull Request #29616 · matplotlib/matplotlib · GitHub
Open Graph Title: FIX: Fix unit example so that we can unpin numpy<2.1 by timhoffm · Pull Request #29616 · matplotlib/matplotlib
X Title: FIX: Fix unit example so that we can unpin numpy<2.1 by timhoffm · Pull Request #29616 · matplotlib/matplotlib
Description: 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.
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/29616
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:45df665d-72ad-7f9e-688e-5e48c141cab8 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9D16:20B327:C862E5:109B2A4:6A51922F |
| html-safe-nonce | f31675ccfdcd79579a142bbc9e0e67820688238fe9cf64d3b00185dcad112141 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDE2OjIwQjMyNzpDODYyRTU6MTA5QjJBNDo2QTUxOTIyRiIsInZpc2l0b3JfaWQiOiI0MzY0OTM5MjcyODgyNTkwMjU1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3d7570640b80e0d2037f04604af6729e7f4de817ab7741c7a42634df07f70658 |
| hovercard-subject-tag | pull_request:2334879238 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/29616/files |
| twitter:image | https://avatars.githubusercontent.com/u/2836374?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/2836374?s=400&v=4 |
| og:image:alt | 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... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width