Repository navigation
Conversation
echoix
force-pushed
the
fix-numpy2-oif-nan
branch
from
October 3, 2026 23:40
017e3e1 to
b31cfc6
Compare
echoix
force-pushed
the
fix-numpy2-oif-nan
branch
2 times, most recently
from
October 4, 2026 17:33
4d4cf38 to
3fa227a
Compare
Sorting (oif, bands) tuples that contain NaN has no well-defined order, so the output order of i.oif depended on the sort algorithm. Place NaN results last, in input order, and update the test to expect that. The get_raster_for_points doctest in grass.pygrass.utils expected `1`, but numpy 2 prints `np.int32(1)`. Match it with the ellipsis directive already present. Both showed up when running the full Ubuntu test configuration with the latest Python and numpy. Written with the help of Claude Code.
echoix
force-pushed
the
fix-numpy2-oif-nan
branch
from
October 4, 2026 17:34
3fa227a to
b633adc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
grass.pygrass.utils.get_raster_for_pointsdoctest: the expected output uses...1..., which the existing+ELLIPSISdirective matches with both numpy 1 and numpy 2.i.oif: NaN results are sorted last, in input order, andtest_constant_raster_yields_nanexpects that order. This changes the output order ofi.oifwhen an input band has zero variance.Motivation and context
With numpy 2, the doctest prints
np.int32(1)instead of1. Sorting(oif, bands)tuples that contain NaN has no well-defined order, so thei.oifoutput order depended on the sort algorithm.These are the failures seen in OSGeo#4372, so this change improves the situation there, even though adding Python 3.13 support is not the goal of this PR.
How has this been tested?
The Ubuntu and macOS gunittest jobs run
test_pygrass_doctests.pyandtest_i_oif.pyand pass. Both use numpy 1.26.4. The Windows (OSGeo4W) job uses numpy 2.4.6: theget_raster_for_pointsexamples pass there, and only the finalremove()cleanup example fails on a Windows file-locking error.Types of changes
functionality to not work as before)
Checklist
pre-defined prefixes
of this project.
Written with the help of Claude Code.