Name kriging singular-fallback variance '{name}_variance'#3289
Merged
brendancol merged 2 commits intoJun 12, 2026
Conversation
brendancol
commented
Jun 12, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
PR Review: Name kriging singular-fallback variance '{name}_variance'
Blockers (must fix before merge)
-
.claude/sweep-api-consistency-state.csv: the rewrite flipped every line ending from LF to CRLF (csv.DictWriterdefaults to\r\nwhen the file is opened withnewline=''). The diff touches all 13 rows instead of adding one, and since the state file merges as plain text (#2754), this will whole-file-conflict with every other sweep branch that commits a row. Rewrite withlineterminator='\n'so the diff is just the newinterpolaterow.
Suggestions (should fix, not blocking)
- none
Nits (optional improvements)
- none
What looks good
- The fix is the minimal correct change:
_kriging.py:499now renames the copied DataArray tof'{name}_variance', matching the normal path at line 527. test_return_variance_name_on_singular_fallbackforces the singular path by monkeypatching_build_kriging_matrix(whichkriging()resolves as a module global, so the patch takes effect) and checks both names plus the NaN contents.- The existing
test_return_variancenow pins the default names on the normal path, so a regression in either path gets caught.
Checklist
- Algorithm matches reference/paper (naming-only change, no numerics touched)
- All implemented backends produce consistent results (fallback runs before backend dispatch)
- NaN handling is correct (fallback still returns all-NaN rasters; test asserts it)
- Edge cases are covered by tests (singular path was previously untested)
- Dask chunk boundaries handled correctly (n/a)
- No premature materialization or unnecessary copies
- Benchmark exists or is not needed (n/a for a name fix)
- README feature matrix updated (n/a)
- Docstrings present and accurate (kriging docstring already describes the tuple return)
- State CSV line endings (see blocker)
e3fd965 to
03b31d2
Compare
brendancol
commented
Jun 12, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
Follow-up review after blocker fix
The CSV blocker from the first review is resolved: the state file is now main's bytes plus a single inserted interpolate row (1 insertion, 0 deletions against main), so other rows keep their existing line endings (two rows on main end with CRLF; they are untouched). No whole-file conflict risk for sibling sweep branches.
The code and test changes are unchanged from the first review and still look correct. pytest xrspatial/tests/test_interpolation.py passes (67) after the rebase.
No remaining findings.
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.
Closes #3285
kriging(..., return_variance=True)has a fallback for the case where the kriging matrix stays singular after regularisation: it returns NaN rasters viaprediction, prediction.copy(). The copy kept the prediction's name, so both arrays came back named'{name}'while the normal path names the variance'{name}_variance'. Anything keying on.name(xr.merge, building a Dataset from the pair) collapsed the two into one variable.f'{name}_variance', matching the normal path.test_return_variance.Backend coverage: the fallback runs before backend dispatch, so one code path covers numpy, cupy, dask+numpy, and dask+cupy. Variance names on the normal path were verified on numpy and cupy.
Test plan:
test_return_variance_name_on_singular_fallbackforces the singular path via monkeypatch and checks both names plus NaN contentspytest xrspatial/tests/test_interpolation.py-- 67 passed