interpolate: align IDW all-points and k-nearest on coincident inputs#1
Open
jam-lock wants to merge 1 commit into
Open
interpolate: align IDW all-points and k-nearest on coincident inputs#1jam-lock wants to merge 1 commit into
jam-lock wants to merge 1 commit into
Conversation
…nputs The numba/CUDA all-points kernels used to `break` on the first input point with d2==0 and return that point's z, while the scipy.cKDTree k-nearest path averaged the z values of all coincident matches. The two backends thus produced numerically different results on the same input -- a Cat 5 (backend inconsistency) accuracy bug. Both all-points kernels now accumulate the sum and count of coincident points and return the mean, matching the k-nearest path. This is also the mathematically correct IDW limit at a coincident grid cell. Adds TestIDW.test_duplicate_points_average_across_backends as the regression test. Updates .claude/sweep-accuracy-state.csv with the interpolate row for the deep-sweep accuracy run on 2026-05-21.
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.
Summary
Accuracy sweep for the
interpolatemodule surfaced a Cat 5 backenddivergence in
idw(): the numba/CUDA all-points kernels broke on thefirst input point with
d2 == 0and returned that point'sz, whilethe scipy.cKDTree k-nearest path averaged all coincident matches.
Same input, different numerical results.
coincident input points and return the mean, matching the
k-nearest path.
grid cell (the 1/d^p weights diverge equally for each coincident
point).
through the same updated kernels.
The state CSV update for the 2026-05-21 deep-sweep accuracy run is
included in the same commit.
Test plan
pytest xrspatial/tests/test_interpolation.py(37 passed, 5 skipped on CPU host)TestIDW.test_duplicate_points_average_across_backendsregression test exercises the bug and passes both paths
no CUDA; the change is a direct port of the CPU fix into the
@cuda.jitkernel)