Skip to content

Add kriging test coverage (#2921)#2928

Open
brendancol wants to merge 1 commit into
mainfrom
deep-sweep-test-coverage-interpolate-kriging-2026-06-04
Open

Add kriging test coverage (#2921)#2928
brendancol wants to merge 1 commit into
mainfrom
deep-sweep-test-coverage-interpolate-kriging-2026-06-04

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

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+numpy return_variance=True branch (_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).
  • nlags coverage: added a non-default nlags=5 case plus the invalid-input paths (nlags=0 and nlags=-1 raise ValueError, nlags=2.5 raises TypeError).
  • test_two_point_warns_few_lag_bins: a two-point input produces fewer than 3 lag bins and warns; asserts the UserWarning and finite output.
  • test_kriging_all_nan_points: all-NaN input raises ValueError (only the idw equivalent was tested before).
  • test_output_metadata: output preserves template coords, dims, attrs, and name.
  • 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
  • cupy / dask+cupy tests executed (not skipped) on a CUDA host

@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Jun 4, 2026
)

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.
@brendancol brendancol force-pushed the deep-sweep-test-coverage-interpolate-kriging-2026-06-04 branch from 12018cc to a09d872 Compare June 4, 2026 15:44
Copy link
Copy Markdown
Contributor Author

@brendancol brendancol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_metadata sets template.attrs['res'] on the local template. That is fine because _make_template builds 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_variance branch (_kriging_dask_numpy._chunk_var) was the one backend path with no test. The new test_dask_return_variance_matches_numpy closes it, and uses atol=1e-12 to match the existing dask+cupy variance test (the variance values sit around 1e-14, where rtol is meaningless).
  • The single-point xfail is strict=True with raises=ValueError, so it converts to a failure the moment #2920 is fixed. The source fix is correctly kept out of this PR.
  • Invalid-nlags paths 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test coverage gaps in interpolate/_kriging.py (backend, params, edge cases)

1 participant