Skip to content

Add GPU and edge-case test coverage for spline()#2927

Merged
brendancol merged 1 commit into
mainfrom
deep-sweep-test-coverage-interpolate_spline-2026-06-04
Jun 4, 2026
Merged

Add GPU and edge-case test coverage for spline()#2927
brendancol merged 1 commit into
mainfrom
deep-sweep-test-coverage-interpolate_spline-2026-06-04

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

What

Test-only PR from a scoped test-coverage sweep on the spline interpolator. No source changes.

spline() registers four backends through ArrayTypeFunctionMapping, but TestSpline only exercised numpy and dask+numpy. The cupy and dask+cupy paths, including the _tps_cuda_kernel CUDA kernel, had no test coverage. Kriging already has GPU parity tests; spline did not.

Changes

  • test_cupy_matches_numpy and test_dask_cupy_matches_numpy on TestSpline, guarded with the existing cuda_and_cupy_available / dask_array_available decorators.
  • test_two_point_affine_fit covering the n == 2 least-squares affine branch in _tps_build_and_solve.
  • test_output_metadata asserting the output keeps the template's coords, dims, attrs, and name.

Backend coverage

numpy, cupy, dask+numpy, dask+cupy all exercised for spline now.

Test plan

  • pytest xrspatial/tests/test_interpolation.py::TestSpline -- 9 passed on a CUDA host (both GPU parity tests ran, not skipped)
  • pytest xrspatial/tests/test_interpolation.py -- 45 passed

No GH issue is linked: issue creation was blocked by the local auto-mode classifier during this run.

TestSpline only exercised numpy and dask+numpy. The cupy and dask+cupy
paths (including the _tps_cuda_kernel CUDA kernel) ran with no tests,
unlike kriging which has full GPU parity coverage.

Adds, all test-only:
- test_cupy_matches_numpy, test_dask_cupy_matches_numpy (GPU parity,
  guarded with cuda_and_cupy_available / dask_array_available)
- test_two_point_affine_fit covering the n==2 least-squares branch in
  _tps_build_and_solve
- test_output_metadata asserting coords/dims/attrs/name preservation

Verified all four spline backends green on a CUDA host (45 passed).

deep-sweep test-coverage (scope=spline-only); GH issue creation was
denied by the auto-mode classifier, so no issue is linked.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Jun 4, 2026
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.

PR Review: Add GPU and edge-case test coverage for spline()

Test-only PR. No source changes, so the checks below apply to the tests, not to new production code.

Blockers

None.

Suggestions

None.

Nits

  • test_cupy_matches_numpy and test_dask_cupy_matches_numpy both use a 3x3 square grid. A non-square grid (e.g. 2x3) would exercise the kernel's row/col indexing harder, but the existing kriging GPU tests in this file use square grids too, so matching the convention is fine.

What looks good

  • Both GPU tests reuse the existing cuda_and_cupy_available / dask_array_available decorators and the _to_numpy helper, matching the kriging tests in the same file.
  • test_two_point_affine_fit pins the n==2 affine-fit branch with a hand-checkable oracle: (0,0)->10 and (2,0)->20 give a pure x-gradient, so x=1 reads 15 and x=2 reads 20.
  • test_output_metadata checks coords, dims, attrs, and name. It goes one step past the IDW metadata test by also asserting attrs equality.
  • The dask_cupy test uses chunks=(2,2) on a 3x3 grid, so it covers ragged (2,1) chunk boundaries.

Checklist

  • All four spline backends covered now (numpy, cupy, dask+numpy, dask+cupy): yes
  • GPU tests guarded with skip decorators: yes
  • Edge cases (n==2 branch, metadata) covered: yes
  • Reference values hand-checked, not just "runs without crashing": yes
  • Temp files uniquely named: n/a, none
  • Docstrings on tests: present

@brendancol brendancol merged commit fb343b5 into main Jun 4, 2026
9 checks passed
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.

1 participant