from_template: dask-aligned extents and explicit height/width#3567
Conversation
The default dask grid now pads its shape up to whole blocks, so every chunk is full-size instead of leaving a ragged remainder on the far edge. Padding only happens on a dask backend under the default tiling: eager grids and an explicit chunks= keep the exact bbox-derived shape, and a grid small enough to stay one chunk is left alone. Also adds height/width: pass both to fix the grid shape exactly. The extent floats off the region's lower-left anchor (shape x resolution when a resolution is given, otherwise the resolution is derived so the shape spans the region bbox). Claude-Session: https://claude.ai/code/session_01RngbqHJk4id4BNY1ironEc
Self-review: from_template dask-aligned extents + height/widthRead the integrated BlockersNone. Suggestions
Nits
Heads-up for reviewersThe deliberate behavior change here: same What looks good
Checklist
|
The cell-cap and chunk-cap errors led with "resolution ..." even when the caller set height/width and never passed a resolution. They now name whichever knob was actually used and adjust the "use a coarser ..." advice to match. Adds tests for the height/width path that were missing: the cap message on an oversized explicit shape, height/width combined with preserve=, and a dask backend with a non-block-multiple shape (stays exact, tiles balanced). Claude-Session: https://claude.ai/code/session_01RngbqHJk4id4BNY1ironEc
|
Addressed in 31765e6:
Not changed: the float-truncation nit ( The dask-vs-eager extent divergence stands as designed and is documented in the docstring and PR body. 279 passed, flake8 clean. |
What
Two changes to
from_template, both so the grid partitions cleanly for dask instead of letting the geographic bbox decide the shape.Default dask tiling pads to whole tiles. A multi-block grid grows its extent out from the lower-left anchor until each axis is a whole number of blocks. Every chunk comes back full-size, no ragged remainder. The requested resolution is unchanged and the padded grid still covers the study area (it only grows).
This is dask-only and scoped so it doesn't disturb the existing paths:
chunks=is honored verbatimNew
height/widthparams. Pass both to set the grid shape exactly, anchored at the region origin, with the extent floating off that anchor:shape x resolutionwhen a resolution is given, otherwise the resolution is derived so the shape spans the region bbox.Heads-up
Same name + resolution now gives a different extent on dask vs eager (dask padded larger, eager exact bbox). That's deliberate, since only the chunked path benefits from tiling, but it does mean backend is no longer a pure execution detail for large grids.
Tests
11 new tests in
test_templates.pycovering the padding (applied; skipped for eager, single-chunk, and explicit-chunks paths; resolution stays exact) and height/width (exact shape, extent floats with and without resolution, validation). Full file: 276 passed, flake8 clean.https://claude.ai/code/session_01RngbqHJk4id4BNY1ironEc