Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates GeoUtils to support NumPy 2.0.
I am not going to merge it now, as some issues arising seem to come from potentially undesirable NumPy masked-array behaviour.
Summary
The issue is the new casting rules for scalars with arrays, especially for integers, see here: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#changes-to-numpy-data-type-promotion and https://numpy.org/neps/nep-0050-scalar-promotion.html#nep50 for details.
The above rules make sense, but don't seem to behave the same for masked array. Somehow, we cannot easily cast an integer with a masked array of lower integer-type anymore:
For instance:
runs fine.
But:
yields:
Additionally
With the new scalar casting behaviour, we might have to relax the current behaviour of
Raster.data.setter()
expecting the same data type, otherwise this type of command to simply update the array:might fail a lot.
We can dive into this in more details once the above exception is clarified.
Steps forward
I will open an issue on NumPy's GitHub after triple-checking if this is intended behaviour, but I don't think so.