test_zonal: close HIGH backend-coverage gaps for crosstab/regions/trim/crop/apply#2530
Merged
Merged
Conversation
Contributor
Author
PR Review: test_zonal backend-coverage gaps for crosstab / regions / trim / crop / applyBlockersNone. Source untouched, 32 new tests, all pass on a CUDA host. Suggestions (applied in 610e455)
Suggestions (deferred)
Nits (applied)
Nits (skipped)
What looks good
Checklist
|
610e455 to
2491dda
Compare
… trim / crop / apply Adds test_zonal_backend_coverage_2026_05_27.py (32 tests, all passing on a CUDA host) covering test-coverage gaps surfaced by the deep-sweep test-coverage pass on the zonal module. Cat 1 HIGH backend coverage: - crosstab cupy + dask+cupy parity vs numpy (_crosstab_cupy / _crosstab_dask_cupy were registered in ArrayTypeFunctionMapping but never invoked by any test). - regions cupy + dask+cupy parity vs numpy (cupyx.scipy.ndimage label branch + dask+cupy compute-then-label branch). - trim dask+numpy + cupy + dask+cupy parity (the cupy data.get() path and the dask _trim_bounds_dask isnan branch were untested). - crop dask+numpy + cupy + dask+cupy parity (matching _crop_bounds_dask branch). - apply 3D cupy + dask+cupy parity (per-layer kernel launch over the third axis; existing 3D apply tests covered numpy + dask+numpy only). Cat 3 MEDIUM geometric edges: - 1x1 single-pixel raster on trim / crop. - 1xN and Nx1 strips on regions. Cat 4 LOW parameter coverage: - regions(neighborhood=6) -> ValueError pin. - suggest_zonal_canvas(crs='Geographic') aspect-ratio pin and invalid-crs KeyError. - crosstab cupy with zone_ids / cat_ids subset. - crosstab cupy with agg='percentage'. Cat 5 MEDIUM metadata propagation: - regions preserves coords + attrs (numpy + dask+numpy). - trim / crop set name and preserve attrs. Also pins the documented numpy-vs-dask trim asymmetry on the NaN sentinel: numpy _trim uses equality (never matches NaN), dask _trim_bounds_dask has a dedicated isnan branch. Mutation against cupy.asnumpy() in _crosstab_cupy flipped test_crosstab_cupy_matches_numpy red, confirming the test detects regressions. Source untouched.
- Lift duplicated _canonical_labels helper to module scope so a fix lands once instead of twice (was duplicated in test_regions_cupy_matches_numpy and test_regions_dask_cupy_matches_numpy). - Import cuda_and_cupy_available and dask_array_available from general_checks instead of redeclaring locally. dask_required is now a single-line alias of the shared decorator. - Drop unused imports (zonal.stats, has_cuda_and_cupy) flagged by flake8. - Tighten test_suggest_zonal_canvas_geographic_crs docstring (removed an unedited mid-sentence "wait..." correction). zones_ids=... parameter rename to zone_ids=... is intentionally deferred to rebase: this branch is behind origin/main, the rename + deprecation shim only exist on main, so renaming here would break the tests on this branch. 32 tests still pass on the CUDA host.
2491dda to
683e0dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes test-coverage gaps surfaced by the deep-sweep test-coverage pass on the
zonalmodule (2026-05-27). Addstest_zonal_backend_coverage_2026_05_27.pywith 32 tests, all passing on a CUDA host. Source code is untouched.Cat 1 HIGH -- backend coverage
crosstabcupy + dask+cupy parity vs numpy._crosstab_cupyand_crosstab_dask_cupyare registered inArrayTypeFunctionMappingbut no existing test invoked them.regionscupy + dask+cupy parity vs numpy (cupyx.scipy.ndimage.labelpath + dask+cupy compute-then-label path).trimdask+numpy + cupy + dask+cupy parity. The dask path_trim_bounds_dask(with itsisnanbranch) and the cupydata.get()path had no direct coverage.cropdask+numpy + cupy + dask+cupy parity. Same shape of gap astrimfor_crop_bounds_dask.apply3D cupy + dask+cupy parity. Existing 3D apply tests covered numpy + dask+numpy only; the per-layer kernel-launch branches in_apply_cupyand_apply_dask_cupywere untested.Cat 3 MEDIUM -- geometric edge cases
trimandcrop.regions.Cat 4 LOW -- parameter coverage
regions(neighborhood=6)raisesValueError.suggest_zonal_canvas(crs='Geographic')aspect-ratio pin and invalid-crsKeyError.crosstabcupy withzone_idsandcat_idssubset.crosstabcupy withagg='percentage'.Cat 5 MEDIUM -- metadata propagation
regionspreserves coords and attrs on numpy + dask+numpy.trimandcropset the defaultnameand propagateattrs.Also pins the documented numpy-vs-dask
trimasymmetry on the NaN sentinel: numpy_trimuses equality which never matches NaN, dask_trim_bounds_daskhas a dedicatedisnanbranch.Mutation test: dropping
cupy.asnumpy()in_crosstab_cupyflippedtest_crosstab_cupy_matches_numpyred, confirming the test detects regressions.Test plan
pytest xrspatial/tests/test_zonal_backend_coverage_2026_05_27.py-> 32 passed on CUDA host_crosstab_cupy-> test fails as expectedxrspatial/zonal.pyis untouched (md5 verified)test_zonal.pytests still pass