Skip to content

polygonize: validate raster/mask inputs#1442

Merged
brendancol merged 1 commit intomainfrom
issue-1441
May 4, 2026
Merged

polygonize: validate raster/mask inputs#1442
brendancol merged 1 commit intomainfrom
issue-1441

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #1441.

Summary

  • Add _validate_raster on raster and on mask (when supplied) at the top of polygonize().
  • Bad input now raises TypeError / ValueError from the public API instead of AttributeError deeper in the function.

Test plan

  • 4 new tests in TestPolygonizeInputValidation.
  • pytest xrspatial/tests/test_polygonize.py — 114 passed (110 existing + 4 new).
  • CI run on full suite.

polygonize() previously checked only raster.ndim != 2.  Non-DataArray
inputs raised AttributeError on .data; complex dtypes failed inside
numba with confusing errors.  The optional mask was not validated.

- Add _validate_raster on raster (numeric, ndim=2).
- Add _validate_raster on mask (numeric=False so bool mask works).

4 new tests in TestPolygonizeInputValidation.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 3, 2026
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).
@brendancol brendancol merged commit 26ad1d5 into main May 4, 2026
11 checks passed
@brendancol brendancol deleted the issue-1441 branch May 4, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

polygonize: add _validate_raster on raster input

1 participant