Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions xrspatial/morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def _morph_chunk_numpy(chunk, kernel, op, block_info=None):
else:
interior = _dilate_kernel_numpy(chunk, kernel, rows, cols, ky, kx)
result = chunk.copy()
result[hy:-hy, hx:-hx] = interior
result[hy:hy + rows, hx:hx + cols] = interior
return result


Expand Down Expand Up @@ -388,7 +388,7 @@ def _morph_chunk_cupy(chunk, kernel, op, block_info=None):
else:
_dilate_gpu[bpg, tpb](chunk, kern_dev, out, hy, hx, ky, kx)
result = chunk.copy()
result[hy:-hy, hx:-hx] = out
result[hy:hy + rows, hx:hx + cols] = out
return result


Expand Down
24 changes: 24 additions & 0 deletions xrspatial/tests/test_morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,30 @@ def test_closing_dask_equals_numpy():
assert_numpy_equals_dask_numpy(numpy_agg, dask_agg, morph_closing, nan_edges=True)


@dask_array_available
@pytest.mark.parametrize("kernel", [
np.array([[1, 1, 1]], dtype=np.uint8),
np.array([[1], [1], [1]], dtype=np.uint8),
])
def test_erode_dask_1d_kernel_matches_numpy(kernel):
numpy_agg = create_test_raster(_DATA, backend='numpy')
dask_agg = create_test_raster(_DATA, backend='dask')
fn = partial(morph_erode, kernel=kernel)
assert_numpy_equals_dask_numpy(numpy_agg, dask_agg, fn, nan_edges=False)


@dask_array_available
@pytest.mark.parametrize("kernel", [
np.array([[1, 1, 1]], dtype=np.uint8),
np.array([[1], [1], [1]], dtype=np.uint8),
])
def test_dilate_dask_1d_kernel_matches_numpy(kernel):
numpy_agg = create_test_raster(_DATA, backend='numpy')
dask_agg = create_test_raster(_DATA, backend='dask')
fn = partial(morph_dilate, kernel=kernel)
assert_numpy_equals_dask_numpy(numpy_agg, dask_agg, fn, nan_edges=False)


# ---------------------------------------------------------------------------
# CuPy backend
# ---------------------------------------------------------------------------
Expand Down
Loading