rasterize: validate resolution and chunks (#2066)#2070
Merged
Conversation
resolution must be finite and > 0; reject before dimension math so inf/-1 no longer silently produce a 1x1 raster and 0/nan no longer fall through to opaque downstream errors. chunks must be positive; chunks=0 used to hang _normalize_chunks (the loop condition decremented by zero), negatives diverged. Closes #2066
Docstring follow-up for the validation added in 5fd27cc: note that resolution must be finite and > 0, and chunks must be > 0.
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
resolutionmust be finite and > 0. Previously,infand-1silently produced a 1x1 raster,0raisedZeroDivisionError, andnanraised an opaque int-conversion error. Now all four raise a clearValueErrorbefore any dimension math.chunksmust be positive.chunks=0used to hang_normalize_chunks(the loop decrementedremainingby zero); negative values diverged. Both now raiseValueError.Closes #2066
Test plan
TestValidationcovering scalar resolution (0, -1, -0.5, inf, -inf, nan), tuple resolution (mixed bad/good values), and chunks (0, -1, mixed-axis bad).