Title: Fix inplace arithmetic operators for numpy>=2 by apdavison · Pull Request #271 · python-quantities/python-quantities · GitHub
Open Graph Title: Fix inplace arithmetic operators for numpy>=2 by apdavison · Pull Request #271 · python-quantities/python-quantities
X Title: Fix inplace arithmetic operators for numpy>=2 by apdavison · Pull Request #271 · python-quantities/python-quantities
Description: The reason for the broken in-place behaviour reported in #254 and #258 is that with NumPy 1.x, super().__imul__(other) calls self.__array_prepare__(self, context), which calculates the correct units, but _array_prepare__ was removed from NumPy in NumPy 2.0. This is an inelegant quick fix, calling self.__array_prepare__(self, context) explicitly. It's inelegant because we have to reconstruct context, and we have similar code in multiple places. This will hopefully be enough to get a release out quickly, then we can revisit this when we have more time and fix it properly, probably by implementing __array_ufunc__. See: https://numpy.org/devdocs/release/2.0.0-notes.html#array-prepare-is-removed https://numpy.org/neps/nep-0013-ufunc-overrides.html
Open Graph Description: The reason for the broken in-place behaviour reported in #254 and #258 is that with NumPy 1.x, super().__imul__(other) calls self.__array_prepare__(self, context), which calculates the correct unit...
X Description: The reason for the broken in-place behaviour reported in #254 and #258 is that with NumPy 1.x, super().__imul__(other) calls self.__array_prepare__(self, context), which calculates the correct unit...
Opengraph URL: https://github.com/python-quantities/python-quantities/pull/271
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:bad9356e-295c-df68-1b60-205a00b8d5bd |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8F1E:1A500C:9E8053:CEA847:696AF4D0 |
| html-safe-nonce | e4dd4a7e3307643d75e41468ede6717533a57815faf705e004c5bc1346a75e6e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjFFOjFBNTAwQzo5RTgwNTM6Q0VBODQ3OjY5NkFGNEQwIiwidmlzaXRvcl9pZCI6IjIxODIxNjUyNDAxMDA4Nzc1MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3afef3d3fc2c8d723ba28ccac357bdbb667486809facd2c4bbe05325625f3ea4 |
| hovercard-subject-tag | pull_request:3178810386 |
| 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/python-quantities/python-quantities/pull/271/files |
| twitter:image | https://avatars.githubusercontent.com/u/260552?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/260552?s=400&v=4 |
| og:image:alt | The reason for the broken in-place behaviour reported in #254 and #258 is that with NumPy 1.x, super().__imul__(other) calls self.__array_prepare__(self, context), which calculates the correct unit... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python-quantities/python-quantities git https://github.com/python-quantities/python-quantities.git |
| octolytics-dimension-user_id | 222003 |
| octolytics-dimension-user_login | python-quantities |
| octolytics-dimension-repository_id | 560911 |
| octolytics-dimension-repository_nwo | python-quantities/python-quantities |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 560911 |
| octolytics-dimension-repository_network_root_nwo | python-quantities/python-quantities |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width