hydro: add _validate_raster on secondary DataArray args#1426
Merged
brendancol merged 1 commit intomainfrom May 4, 2026
Merged
Conversation
Each of the following public functions previously validated only its primary raster. A non-DataArray, 1-D DataArray, or None for the secondary arg raised a confusing AttributeError / IndexError from inside the implementation rather than a clean ValueError from the public API. Functions touched (secondary arg in parens): - watershed_d8 / watershed_dinf / watershed_mfd (pour_points) - snap_pour_point_d8 (pour_points) - flow_path_d8 / flow_path_dinf / flow_path_mfd (start_points) - stream_link_d8 / stream_link_dinf / stream_link_mfd (flow_accum) - stream_order_d8 / stream_order_dinf / stream_order_mfd (flow_accum) 13 new tests in test_validate_secondary_args.py confirm each function rejects a numpy ndarray for its secondary arg.
brendancol
added a commit
that referenced
this pull request
May 3, 2026
Records the 11 PRs filed this round: - hydro: HIGH flow_direction_mfd memory guard (PR #1424); MEDIUM bundles for _validate_raster on secondary args (#1426), scalar param validation (#1428), and cellsize validation (#1430). - reproject: MEDIUM bundles for _validate_raster (#1432), grid/bounds/ precision validation (#1434), and NaN/Inf rejection (#1436). - flood: mannings_n DataArray validation (#1438). - pathfinding: waypoint cap + _validate_raster (#1440). - polygonize: _validate_raster (#1442). - terrain: scratch memory guard + scalar validation (#1444).
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 #1425.
Summary
_validate_rasteron the secondary DataArray arg of 13 hydro public functions:watershed_*/snap_pour_point_d8(pour_points),flow_path_*(start_points),stream_link_*/stream_order_*(flow_accum).TypeError/ValueErrorfrom the public API instead of anAttributeErrorfrom inside the implementation.Test plan
pytest xrspatial/hydro/tests/test_validate_secondary_args.py— 13 new passes covering every touched function.pytest xrspatial/hydro/tests/— 774 + 13 = 787 passed.