Skip to content

Add diffusion test coverage for cupy/dask+cupy, reflect boundary, and edge shapes#3424

Open
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-test-coverage-diffusion-2026-06-20
Open

Add diffusion test coverage for cupy/dask+cupy, reflect boundary, and edge shapes#3424
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-test-coverage-diffusion-2026-06-20

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Closes #3422

diffuse() dispatches to all four backends through ArrayTypeFunctionMapping, but the test file only exercised numpy and dask+numpy. This adds the missing coverage. Tests only, no source changes.

  • cupy and dask+cupy parity against the numpy result
  • reflect boundary mode across numpy, dask, cupy, and dask+cupy (previously only nearest and wrap were tested)
  • 1x1 single-pixel and Nx1 / 1xN strip rasters, including a chunked dask strip
  • all-NaN and Inf inputs

Backend coverage: numpy, cupy, dask+numpy, dask+cupy. The four GPU tests ran on a CUDA host before this PR; CI reruns them on its own GPU runner. The reflect/strip/NaN/Inf cases also confirmed all paths produce correct results today, so #3422 is a coverage gap, not a latent bug.

Test plan:

  • pytest xrspatial/tests/test_diffusion.py -> 39 passed (was 24)
  • 14 new tests pass, including 4 cupy / dask+cupy tests executed on a CUDA host

…3422)

The diffuse() dispatch table registers all four backends but the tests
only exercised numpy and dask+numpy. Add:

- cupy and dask+cupy parity tests (numpy reference)
- reflect boundary mode across numpy/dask/cupy/dask+cupy
- 1x1 single-pixel and Nx1/1xN strip rasters
- all-NaN and Inf inputs

Test-only; no source changes.

@brendancol brendancol left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PR Review: Add diffusion test coverage for cupy/dask+cupy, reflect boundary, and edge shapes

Test-only PR. No source changed, so the correctness checks apply to the tests themselves, not to new library code.

Blockers

None.

Suggestions

None.

Nits

  • test_inf_input_propagates_like_nan: the assertion on the Inf cell's neighbour is np.isnan(out[1, 2]) or np.isinf(out[1, 2]). That is a deliberately loose smoke check given Inf arithmetic is brittle, which is fine, but it would still pass if the behaviour flipped from inf to nan. Worth a one-line comment saying that is intentional so a future reader does not tighten it by mistake.

What looks good

  • All four backends are exercised. The cupy and dask+cupy tests are guarded with cuda_and_cupy_available, so they skip on non-GPU hosts and run on CI's GPU runner.
  • Cross-backend parity uses the shared general_checks.py helpers with reasonable tolerances (1e-7 cupy, 1e-6 dask+cupy for reduction-order differences).
  • The edge cases line up with the issue: 1x1, Nx1, 1xN, all-NaN, Inf, plus the previously untested reflect boundary.
  • The dask strip test chunks across the strip (chunks=(4,1)), so it exercises the overlap path instead of collapsing to one chunk.

Checklist

  • All implemented backends produce consistent results (parity tests)
  • NaN handling correct (equal_nan, all-NaN and propagation tests)
  • Edge cases covered
  • Dask chunk boundaries handled (strip chunked across the overlap)
  • No source changes -> no benchmark/README/docstring updates needed
  • Tests pass locally: 39 passed, including 4 GPU tests on a CUDA host

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diffusion: no test coverage for cupy / dask+cupy backends, reflect boundary, or 1x1/strip rasters

1 participant