Add kriging test coverage (#2921)#2928
Open
brendancol wants to merge 1 commit into
Open
Conversation
) Closes gaps found by the test-coverage sweep on interpolate/_kriging.py: - dask+numpy return_variance branch (_chunk_var) was unexercised - nlags only tested at default; added non-default + invalid-input paths - two-point <3-lag-bins UserWarning path - all-NaN kriging input ValueError (only idw was covered) - output metadata preservation (coords/dims/attrs/name) - xfail test documenting single-point crash (source bug #2920) Test-only; no source changes. GPU paths validated on a CUDA host.
12018cc to
a09d872
Compare
brendancol
commented
Jun 4, 2026
Contributor
Author
brendancol
left a comment
There was a problem hiding this comment.
Review: Add kriging test coverage (#2928)
Test-only PR. I read the full test file and the kriging source, and ran the suite on a CUDA host (49 passed, 1 xfailed).
Blockers
None.
Suggestions
None.
Nits
test_output_metadatasetstemplate.attrs['res']on the local template. That is fine because_make_templatebuilds a fresh DataArray per call, so there is no leakage into other tests. No change needed; noting it for the record.
What looks good
- The dask+numpy
return_variancebranch (_kriging_dask_numpy._chunk_var) was the one backend path with no test. The newtest_dask_return_variance_matches_numpycloses it, and usesatol=1e-12to match the existing dask+cupy variance test (the variance values sit around 1e-14, wherertolis meaningless). - The single-point xfail is
strict=Truewithraises=ValueError, so it converts to a failure the moment #2920 is fixed. The source fix is correctly kept out of this PR. - Invalid-
nlagspaths are split by exception type (ValueError for below-min, TypeError for non-int), matching_validate_scalar. - All four backends now have parity tests; cupy and dask+cupy ran (not skipped) on the CUDA host.
Checklist
- No source changes; behavior unchanged
- All implemented backends exercised, GPU validated
- NaN / edge cases covered (all-NaN input, two-point sparse, single-point xfail)
- Dask variance branch now tested
- No premature materialization introduced
- Benchmark not applicable (test-only)
- Docstrings / README not applicable (no API change)
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 #2921
Test-only PR. No source changes. Fills coverage gaps the test-coverage sweep found in
xrspatial/interpolate/_kriging.py.What changed
test_dask_return_variance_matches_numpy: the dask+numpyreturn_variance=Truebranch (_kriging_dask_numpy._chunk_var) had no test. The dask+cupy variance path was already covered; this matches that pattern (atol=1e-12, since the variance values sit near 1e-14).nlagscoverage: added a non-defaultnlags=5case plus the invalid-input paths (nlags=0andnlags=-1raiseValueError,nlags=2.5raisesTypeError).test_two_point_warns_few_lag_bins: a two-point input produces fewer than 3 lag bins and warns; asserts theUserWarningand finite output.test_kriging_all_nan_points: all-NaN input raisesValueError(only theidwequivalent was tested before).test_output_metadata: output preserves template coords, dims, attrs, andname.test_single_point:xfail(strict, raises=ValueError)documenting the single-point crash. That is a real source bug (kriging() crashes on single-point input with "zero-size array to reduction maximum" #2920); the fix is left to that issue so this PR stays test-only.Backend coverage
numpy, cupy, dask+numpy, dask+cupy all have parity tests. The new dask+numpy variance test closes the one backend branch that had no coverage. All GPU tests ran green on a CUDA host.
Test plan
pytest xrspatial/tests/test_interpolation.py -k "Kriging or kriging"-> 22 passed, 1 xfailed