Skip to content

rasterize: validate resolution and chunks (#2066)#2070

Merged
brendancol merged 2 commits into
mainfrom
issue-2066
May 18, 2026
Merged

rasterize: validate resolution and chunks (#2066)#2070
brendancol merged 2 commits into
mainfrom
issue-2066

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

  • resolution must be finite and > 0. Previously, inf and -1 silently produced a 1x1 raster, 0 raised ZeroDivisionError, and nan raised an opaque int-conversion error. Now all four raise a clear ValueError before any dimension math.
  • chunks must be positive. chunks=0 used to hang _normalize_chunks (the loop decremented remaining by zero); negative values diverged. Both now raise ValueError.

Closes #2066

Test plan

  • Added parametrized cases in TestValidation covering scalar resolution (0, -1, -0.5, inf, -inf, nan), tuple resolution (mixed bad/good values), and chunks (0, -1, mixed-axis bad).
  • Full rasterize test suite still passes (171 passed, 2 skipped).

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
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 18, 2026
Docstring follow-up for the validation added in 5fd27cc: note that
resolution must be finite and > 0, and chunks must be > 0.
@brendancol brendancol merged commit 4e3abcd into main May 18, 2026
4 of 5 checks passed
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.

rasterize: invalid resolution and chunks values are accepted (chunks=0 hangs)

1 participant