You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FIX: Fix unit example so that we can unpin numpy>2.1
Closesmatplotlib#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.
`
0 commit comments