Fix disaggregate(limiting_variable) silently losing a zone's value (#3403)#3414
Open
brendancol wants to merge 1 commit into
Open
Fix disaggregate(limiting_variable) silently losing a zone's value (#3403)#3414brendancol wants to merge 1 commit into
brendancol wants to merge 1 commit into
Conversation
…array-contrib#3403) When a zone has no pixel that can absorb its value (every pixel falls in a cap-0 class, e.g. all zero-weight under the default caps), the leftover loop found no overflow pixels and discarded the remaining mass, leaving the zone's pixels at their initialised 0. The zone's whole value vanished with no error, breaking the documented conservation property. Match the weighted method: when no pixel can absorb the leftover, set the zone result to NaN instead of silently zeroing it. Also record the accuracy-sweep state for the dasymetric module.
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.
Fixes #3403.
disaggregate(method='limiting_variable')dropped a zone's whole value when the zone had no pixel that could hold it. If every pixel in a zone fell in a cap-0 class (all zero-weight under the default caps), the leftover loop found no overflow pixels and threw the remaining mass away, leaving those pixels at their initialised 0. The value disappeared with no error, even though the docstring promises zone totals are preserved.The
weightedmethod already handles this by returning NaN. This change makeslimiting_variabledo the same: when no pixel can absorb the leftover, the zone's result is NaN instead of silent zeros.Added
test_uninhabitable_zone_is_nan_not_zero, which fails on the old code and passes now. The full dasymetric suite stays green (62 tests, including the cupy and dask+cupy cross-backend checks on this GPU host). The cupy and dask backends route through the numpy core, so the fix reaches all four backends.Found by the accuracy sweep on the
dasymetricmodule.