Skip to content

test(convolution): backend, boundary, and metadata coverage#3621

Open
brendancol wants to merge 1 commit into
mainfrom
deep-sweep-test-coverage-convolution-2026-07-02
Open

test(convolution): backend, boundary, and metadata coverage#3621
brendancol wants to merge 1 commit into
mainfrom
deep-sweep-test-coverage-convolution-2026-07-02

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

What

Adds tests for xrspatial/convolution.py. Before this, the test file had 5 tests
that only touched numpy error paths and the default boundary mode, so branch
coverage sat at 52%.

convolve_2d and convolution_2d dispatch across numpy, cupy, dask+numpy, and
dask+cupy, but only the numpy path was exercised. The boundary parameter has four
public modes and only the default was tested. convolution_2d re-attaches
coords/dims/attrs/name and nothing checked that it does.

New tests

  • Backend parity: convolution_2d numpy vs dask+numpy, cupy, and dask+cupy.
  • Boundary modes: nan/nearest/reflect/wrap on numpy+dask, and a cupy/dask+cupy
    vs numpy comparison over all four modes. Plus the invalid-boundary ValueError.
  • Metadata: convolution_2d preserves coords, dims, attrs, and name; custom name.
  • NaN inside the raster propagates through the kernel window.
  • Degenerate shapes (1x1, 1xN, Nx1) return all-NaN without crashing.
  • Previously untested public functions: calc_cellsize (res attr and km->m unit
    conversion), annulus_kernel, custom_kernel valid/non-ndarray/even-dims, and
    circle_kernel bad radius/unit.

Verification

Ran on a CUDA host, so the cupy and dask+cupy tests executed for real, not just
static review. Full file: 26 passed, including the 3 GPU tests. flake8 and isort
clean.

No source change. No bug surfaced by the new tests. This is test-only.

Branch coverage went from 52% to 72% as measured on CPU (NUMBA_DISABLE_JIT=1).
The cupy kernel lines can't be seen by CPU coverage instrumentation, but they run
under the 3 passing GPU tests.

Found by the test-coverage deep sweep.

Deep-sweep test-coverage on a CUDA host. Branch coverage was 52% with the
test file exercising only numpy error paths and the default boundary mode.

convolve_2d/convolution_2d dispatch to numpy, cupy, dask+numpy, and
dask+cupy, but only the numpy path had tests. Add:

- Backend parity: convolution_2d numpy vs dask+numpy, cupy, dask+cupy
  (Cat 1). Ran and passed on the GPU host.
- Boundary modes: nan/nearest/reflect/wrap on numpy+dask and a
  cupy/dask+cupy-vs-numpy loop; invalid-boundary ValueError (Cat 4).
- Metadata: convolution_2d preserves coords/dims/attrs/name (Cat 5).
- NaN-interior propagation (Cat 2); degenerate 1x1/1xN/Nx1 all-NaN (Cat 3).
- Previously untested public funcs: calc_cellsize, annulus_kernel,
  custom_kernel valid/non-ndarray/even-dims, circle_kernel bad radius/unit.

Full file: 26 passed including 3 GPU tests. No source change; no bug
surfaced. flake8/isort clean.
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.

1 participant