slope: add degenerate-shape test coverage (1x1, 1xN, Nx1)#2703
Merged
Conversation
brendancol
commented
May 29, 2026
Contributor
Author
brendancol
left a comment
There was a problem hiding this comment.
PR Review: slope degenerate-shape test coverage
Blockers
None.
Suggestions
None.
Nits
- test_slope.py:215 The geodesic test asserts shape and all-NaN directly but skips
general_output_checks, whichtest_degenerate_shape_numpy(line 165) calls. The cross-backend helpers already cover attrs/coords on the dask and cupy paths, so this is minor. Addinggeneral_output_checks(raster, result)to the geodesic test would make the attrs/coords/dims check uniform across all five tests.
What looks good
- All four planar backends plus geodesic are covered through the existing helpers in general_checks.py.
nan_edges=Falseis correct here. These outputs are entirely NaN, soassert_nan_edges_effectwould have no non-NaN interior to compare against.- The comment explains why these shapes come back all-NaN (the
range(1, rows-1)loop is empty when rows<=2), so the test pins a real contract instead of freezing whatever the code happens to return today. - Ran locally on a CUDA host: 15 degenerate tests passed, with cupy and dask+cupy actually executing rather than skipping.
Checklist
- Test-only, no algorithm change
- All implemented backends produce consistent results
- NaN handling is correct
- Edge cases covered
- Dask chunk boundaries handled correctly
- No premature materialization
- Benchmark not needed; README matrix and docstrings not applicable
brendancol
commented
May 29, 2026
Contributor
Author
brendancol
left a comment
There was a problem hiding this comment.
Follow-up review
The one nit from the first pass is resolved: the geodesic degenerate-shape test now calls general_output_checks(raster, result), so attrs/coords/dims preservation is asserted uniformly across all five degenerate tests (952062e).
No remaining Blockers, Suggestions, or Nits. Re-ran pytest xrspatial/tests/test_slope.py -k degenerate -> all pass.
brendancol
added a commit
that referenced
this pull request
May 31, 2026
- numpy degenerate-shape test now runs general_output_checks to assert attrs/coords/dims are preserved, matching the slope #2703 convention. - add a geodesic degenerate-shape test (1x1, 1xN, Nx1) so the no-interior case is pinned for method='geodesic' too, not just planar.
4 tasks
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.
Closes #2697
Adds tests for degenerate raster shapes where a dimension is too small for the 3x3 kernel to have an interior. These shapes already work (output keeps the input shape and comes back all-NaN), but nothing pinned that down. A future change to the kernel bounds could start raising or returning the wrong shape and no test would catch it.
test_degenerate_shape_*tests covering shapes (1, 1), (1, 5), (5, 1)Backend coverage: numpy, cupy, dask+numpy, dask+cupy.
Test plan:
pytest xrspatial/tests/test_slope.py -k degenerate-> 15 passed (cupy and dask+cupy ran on a CUDA host, not skipped)pytest xrspatial/tests/test_slope.py xrspatial/tests/test_geodesic_slope.py-> 77 passed