Skip to content

Add proximity coverage tests: int rasters, bounded GPU metrics, empty input (#3139)#3140

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

Add proximity coverage tests: int rasters, bounded GPU metrics, empty input (#3139)#3140
brendancol wants to merge 3 commits into
mainfrom
deep-sweep-test-coverage-proximity-2026-06-09

Conversation

@brendancol

Copy link
Copy Markdown
Contributor

Closes #3139

Test-only PR; xrspatial/proximity.py is untouched.

  • Integer-dtype rasters (int32) now run on all four backends, bounded and unbounded, pinned against the float64 numpy baseline (24 tests + 4 explicit-target_values tests). The bounded dask case is the interesting one: boundary=np.nan on an int array casts the pad to INT_MIN, a finite non-zero "target" value, and the only thing neutralizing those phantom targets is that the coordinate-grid pads are real NaNs.
  • The bounded dask+cupy path (_process_dask_cupy) was only ever exercised with EUCLIDEAN. Added MANHATTAN and GREAT_CIRCLE x {proximity, allocation, direction} against the numpy baseline, with a spy asserting the bounded GPU path actually ran (6 tests). Mutation check: zeroing the halo depth flips all 6 red.
  • Empty (0, N) / (N, 0) rasters now have a fail-fast pin: they raise (currently IndexError from the coordinate-endpoint lookup) instead of returning garbage (6 tests).

Backend coverage: numpy / cupy / dask+numpy / dask+cupy all executed locally on a CUDA host.

Test plan:

  • 40 new tests pass on a CUDA host
  • full test_proximity.py passes (450 passed, 0 skipped)
  • mutation check on the bounded-GPU halo flips the new tests red; source restored byte-identical (md5)

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

@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 proximity coverage tests: int rasters, bounded GPU metrics, empty input (#3139)

Blockers

None.

Suggestions

  • Int coverage was int32-only. uint8 is the usual land-cover dtype and exercises a different NaN-pad cast (lands on a non-target 0 instead of int32's phantom-target INT_MIN). Fixed in be721dd by parametrizing dtype.
  • test_integer_raster_explicit_target_values ran proximity only; allocation and direction never saw integer pixels with explicit target_values. Fixed in be721dd by parametrizing func.

Nits

  • The empty-raster test is numpy-only. That's fine: the raise happens in _process before backend dispatch (the max_possible_distance endpoint lookup), so one backend covers all four. No change needed.

What looks good

  • The spy on _process_dask_cupy means the bounded-GPU metric tests can't silently pass through a fallback path if dispatch thresholds drift.
  • The mutation check (zeroing the halo depth) flipped all 6 bounded tests red, and the source was restored byte-identical.
  • The int tests hit both the unbounded dask KDTree path (max_distance=inf) and the bounded map_overlap halo path (max_distance=10), which is where the NaN-pad cast lives.

Checklist

  • Algorithm reference: n/a, test-only
  • Backend consistency: 72 new tests across numpy / cupy / dask+numpy / dask+cupy, executed on a CUDA host
  • NaN handling: pinned via the int-pad tests
  • Edge cases: empty-raster raise pinned
  • Dask chunk boundaries: bounded halo path now exercised with non-default metrics
  • Benchmark / README / docstrings: not applicable, test-only

…age-proximity-2026-06-09

# Conflicts:
#	xrspatial/tests/test_proximity.py
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.

proximity: test gaps for integer rasters, bounded dask+cupy metrics, empty rasters

1 participant