Raise on 'majority' in zonal_stats dask path instead of silent drop (#2528)#2531
Merged
Conversation
Contributor
Author
|
Review pass (worktree, fresh test run):
Applied one suggestion: the dict-on-dask error message hard-coded the supported list. Sourced it from _DEFAULT_STATS_DASK to prevent drift (1 file, 2 lines). Tests: 129/129 test_zonal.py + 150/150 dasymetric/dataset_support/validation pass. |
…2528) zonal_stats() on dask-backed inputs silently dropped 'majority' from the requested stats list. The default stats_funcs included 'majority' but the dask block-by-block path filtered it out without warning, so callers got fewer columns than the docstring promised. Replace the mutable list default with stats_funcs=None and resolve the default per backend inside the function. Numpy and cupy keep the full eight-stat default; dask resolves to the seven-stat subset without majority. Explicit 'majority' on a dask input now raises ValueError with the supported-stats list. Fixes #2528.
The error raised when a dict is passed for stats_funcs on a dask-backed input hard-coded the supported stats list as a string literal. Source the list from _DEFAULT_STATS_DASK so the message can't drift if the constant changes.
9be320f to
e0a7b7b
Compare
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
stats_funcs=Noneand resolved the default per backend; numpy/cupy keep the full eight-stat default, dask resolves to the seven-stat subset.ValueErrorinstead of being silently filtered.Closes #2528.
Test Plan
pytest xrspatial/tests/test_zonal.py-- 129 pass (125 pre-existing + 4 new regression tests).pytest xrspatial/tests/test_dasymetric.py-- 61 pass (dasymetric uses zonal.stats internally).