Add edge_detection tests for Inf, boundary NaN, degenerate shapes, and multi-chunk dask#3685
Open
brendancol wants to merge 3 commits into
Open
Add edge_detection tests for Inf, boundary NaN, degenerate shapes, and multi-chunk dask#3685brendancol wants to merge 3 commits into
brendancol wants to merge 3 commits into
Conversation
…erate shapes, multi-chunk dask (#3682)
brendancol
commented
Jul 18, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
PR Review: Add edge_detection tests for Inf, boundary NaN, degenerate shapes, and multi-chunk dask
Test-only PR, source untouched. Ran the new suite locally on a CUDA host: 222 passed, GPU tests executed rather than skipped.
Blockers (must fix before merge)
None.
Suggestions (should fix, not blocking)
- Integer dtype input is still untested. #3682 calls out input-space gaps, and
convolve_2dpromotes int32 to float32; a small test pinning the promoted dtype and a known value would close that corner (new sections ofxrspatial/tests/test_edge_detection.py). -
TestInfHandling.test_negative_inf(test_edge_detection.py, ~line 396) only asserts an inf-or-nan mask. The -inf case is the +inf expected block negated with NaN kept, so it could pin exact values the waytest_inf_neighborhooddoes.
Nits (optional improvements)
- The module-level
inf = np.inf/nan = np.nanaliases (test_edge_detection.py, ~line 358) leak into the module namespace for the sake of one parametrize table. Inliningnp.inf/np.nanin the table would keep the namespace clean, at the cost of longer lines.
What looks good
test_inf_neighborhoodpins exact per-operator 3x3 expectations instead of a loose isfinite check, including the 0-weight -> NaN cells.- NaN-at-corner parity runs all 4 boundary modes on all 4 backends; this is the combination that has caught real divergence elsewhere (kde #3628).
- Multi-chunk dask tests (chunks=(4,5) on 9x11, chunks=(3,4) on 8x10) finally exercise chunk stitching from this file; previous dask tests were all single-chunk.
test_invalid_boundary_raisesmatches the pattern aspect/morphology/diffusion/bilateral already use.- The pre-existing E302 at line 22 was left alone (tracked by #3675), no drive-by edits.
Checklist
- Algorithm matches reference/paper (n/a, test-only; expectations match probed behavior)
- All implemented backends produce consistent results
- NaN handling is correct
- Edge cases are covered by tests
- Dask chunk boundaries handled correctly
- No premature materialization or unnecessary copies
- Benchmark exists or is not needed (missing, tracked separately in #3672)
- README feature matrix updated (n/a)
- Docstrings present and accurate (n/a; docstring gaps tracked in #3674/#3676)
brendancol
commented
Jul 18, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
PR Review: follow-up after 65687d4
Re-checked the branch after the review fixes.
Blockers
None.
Suggestions
None. Both earlier suggestions are addressed:
TestIntegerDtype.test_int32_promotes_to_float32pins the float32 promotion and compares against the float64-input result for all five operators.test_negative_infnow asserts the exact negated neighborhood via the sharedINF_NEIGHBORHOODStable instead of an inf-or-nan mask.
The nit is also done: the module-level inf/nan aliases are gone, with the expected blocks built from np.inf/np.nan directly.
Verification
- 227 tests pass locally on a CUDA host (was 222 at first review, 87 before the PR).
- flake8 on the file reports only the pre-existing E302 at line 22 (#3675).
Nothing further from me.
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 #3682
Test-only change from the test-coverage audit of edge_detection. The source is untouched; every new test pins behavior that was verified correct on a CUDA host but had no coverage.
Backends: numpy, cupy, dask+numpy, dask+cupy all exercised; the GPU tests ran locally, not just in CI.
Test plan:
pytest xrspatial/tests/test_edge_detection.pyon a CUDA host: 222 passed (was 87)Also carries the sweep state CSV row for this audit.