Skip to content

Conversation

@apdavison
Copy link
Contributor

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:

…on and division with NumPy 2.x

The reason for the failure is that with NumPy 1.25, `super().__imul__(other)` calls `self.__array_prepare__(self, context)`,
but `_array_prepare__` was removed in NumPy 2.0.
Long-term, we should probably implement `__array_ufunc__`.
This inelegant fix will hopefully be enough to get a release out quickly, then we can revisit this when we have more time and fix it properly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant