Use sized slice in dask morph chunk writeback (#1399)#1400
Merged
Conversation
`result[hy:-hy, hx:-hx] = interior` becomes the empty slice `0:-0` when hy or hx is 0, so 1xN and Nx1 kernels raised ValueError on the dask backends while numpy and cupy paths handled them. Switch both _morph_chunk_numpy and _morph_chunk_cupy to `result[hy:hy + rows, hx:hx + cols] = interior`, and add parametrized 1x3 / 3x1 dask regression tests.
1 task
brendancol
added a commit
that referenced
this pull request
May 1, 2026
…1401) Three modules audited 2026-04-30. - fire: clean (per-pixel ops only; NaN guards via x!=x; CUDA bounds use strict <; division guarded; CPU/GPU/dask paths line-for-line equivalent; no CRIT/HIGH/MEDIUM). - terrain_metrics: LOW only (Inf input not rejected, propagates; dask+cupy non-nan boundary path double-pads with consistent output). - morphology: HIGH x 2 fixed. - #1397 / PR #1398: morph_erode/dilate seeded centre cell into the running min/max even when kernel[centre]==0, contaminating the result with the excluded pixel (all four backends). - #1399 / PR #1400: _morph_chunk_numpy and _morph_chunk_cupy used result[hy:-hy, hx:-hx] which becomes the empty slice 0:-0 for 1xN or Nx1 kernels, raising ValueError on the dask backends while numpy and cupy paths handled them.
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
result[hy:-hy, hx:-hx] = interiorwithresult[hy:hy + rows, hx:hx + cols] = interiorin both_morph_chunk_numpyand_morph_chunk_cupy. The old form became the empty slice0:-0for 1xN or Nx1 kernels, raising ValueError on the dask backends while numpy and cupy paths handled them.morph_erodeandmorph_dilate.Closes #1399
Test plan
pytest xrspatial/tests/test_morphology.py(39 passed, including the 4 new parametrized cases)