Validate input rasters in edge_detection public API (#1271)#1273
Open
brendancol wants to merge 2 commits intomainfrom
Open
Validate input rasters in edge_detection public API (#1271)#1273brendancol wants to merge 2 commits intomainfrom
brendancol wants to merge 2 commits intomainfrom
Conversation
Add _validate_raster(agg) at the top of sobel_x, sobel_y, laplacian, prewitt_x, and prewitt_y so non-DataArray inputs raise TypeError and wrong-ndim DataArrays raise ValueError instead of failing later inside numba or cupy with a confusing message. Numerical correctness is unaffected (convolve_2d already casts integer dtypes to float32). This is purely an error-message UX improvement. Add tests covering numpy.ndarray, 1-D DataArray, and 3-D DataArray inputs for all five functions. Record the inspection in .claude/sweep-security-state.json with severity_max=MEDIUM and categories_found=[6].
Contributor
Author
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
Contributor
Resolved the merge conflict in |
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
_validate_raster(agg)at the top ofsobel_x,sobel_y,laplacian,prewitt_x, andprewitt_y. The sibling modules (aspect, slope, curvature, bilateral) already do this; edge_detection was the outlier.np.ndarray, 1-D DataArray, and 3-D DataArray inputs across all five functions. Non-DataArray now raisesTypeError, wrong-ndim raisesValueError..claude/sweep-security-state.json(severity MEDIUM, Cat 6).Cat 6 finding from the latest security sweep. Numerical correctness was not affected because
convolve_2d._promote_floatalready casts integer dtypes to float32. This is purely an error-message UX fix.Closes #1271.
Test plan
pytest xrspatial/tests/test_edge_detection.py -x(87 passed)TestInputValidationclass covers all five public functions across three failure modes