Skip to content

Use sized slice in dask morph chunk writeback (#1399)#1400

Merged
brendancol merged 1 commit into
mainfrom
issue-1399
May 1, 2026
Merged

Use sized slice in dask morph chunk writeback (#1399)#1400
brendancol merged 1 commit into
mainfrom
issue-1399

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

  • Replaces result[hy:-hy, hx:-hx] = interior with result[hy:hy + rows, hx:hx + cols] = interior in both _morph_chunk_numpy and _morph_chunk_cupy. The old form became the empty slice 0:-0 for 1xN or Nx1 kernels, raising ValueError on the dask backends while numpy and cupy paths handled them.
  • Adds parametrized 1x3 and 3x1 dask regression tests for morph_erode and morph_dilate.

Closes #1399

Test plan

  • pytest xrspatial/tests/test_morphology.py (39 passed, including the 4 new parametrized cases)

`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.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 1, 2026
@brendancol brendancol merged commit 0f7f679 into main May 1, 2026
11 checks passed
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.
@brendancol brendancol deleted the issue-1399 branch May 4, 2026 13:04
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.

morphology: dask backends raise on 1xN or Nx1 kernels (empty-slice bug)

1 participant