Skip to content

Fixes #907, #908: make bump dask backends truly lazy, add agg parameter#914

Merged
brendancol merged 2 commits intomasterfrom
fix-907-908
Feb 27, 2026
Merged

Fixes #907, #908: make bump dask backends truly lazy, add agg parameter#914
brendancol merged 2 commits intomasterfrom
fix-907-908

Conversation

@brendancol
Copy link
Contributor

Summary

  • Add agg template-raster parameter to bump() so shape, chunks, and backend are inferred from an existing DataArray
  • Implement all four backends (NumPy, CuPy, Dask+NumPy, Dask+CuPy) via ArrayTypeFunctionMapping — Dask backends use map_blocks with block_info for truly lazy, per-chunk bump generation
  • Make width/height optional when agg is provided
  • Add comprehensive tests for all backends, coordinate preservation, and shape inference

Test plan

  • Existing test_bump still passes
  • test_bump_agg_numpy — NumPy backend with agg, determinism check
  • test_bump_agg_cupy — CuPy backend matches NumPy (skipped without GPU)
  • test_bump_agg_dask — single-chunk Dask matches NumPy bitwise
  • test_bump_agg_dask_chunked — multi-chunk Dask laziness and approximate energy conservation
  • test_bump_agg_dask_cupy — Dask+CuPy single-chunk matches NumPy (skipped without GPU)
  • test_bump_preserves_coords — coordinates and dims propagated from agg
  • test_bump_agg_infers_shape — shape inferred from agg matches explicit width/height

Closes #907, #908

Rewrite _bump_dask_numpy and _bump_dask_cupy to use da.map_blocks
instead of eagerly allocating the full output array, which would OOM
on large rasters. Each chunk now independently filters bumps whose
center falls within it and computes only the chunk-sized result.

Also add an `agg` template parameter to bump() with full backend
dispatch (numpy, cupy, dask+numpy, dask+cupy) via ArrayTypeFunctionMapping.

Tests use single-chunk for bitwise equality and multi-chunk for
approximate verification of the lazy chunked path.
- Implement _hotspots_dask_cupy: GPU convolution + CPU classification via map_overlap
- Implement _emerging_hotspots_dask_cupy: GPU convolution, CPU Mann-Kendall via map_blocks
- Replace not_implemented_func stubs with real dask_cupy_func in both APIs
- Add tests verifying dask+cupy results match numpy reference
- Update README backend support table for hotspots, emerging hotspots, and bump
@brendancol brendancol merged commit 417e65b into master Feb 27, 2026
10 checks passed
@brendancol brendancol deleted the fix-907-908 branch February 28, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modernise bump() API and add multi-backend support

1 participant