Skip to content

Fix map_overlap in case of single chunk in overlap dimension #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2024
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
2 changes: 1 addition & 1 deletion cubed/overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@ def _pad_boundaries(x, depth, boundary, numblocks, block_id):
p = nxp.full_like(x, fill_value=boundary[i], shape=pad_shape)
if block_id[i] == 0: # first block on axis i
x = nxp.concat([p, x], axis=i)
elif block_id[i] == numblocks[i] - 1: # last block on axis i
if block_id[i] == numblocks[i] - 1: # last block on axis i
x = nxp.concat([x, p], axis=i)
return x
17 changes: 17 additions & 0 deletions cubed/tests/test_overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ def test_map_overlap_1d():
assert_array_equal(b.compute(), np.array([0, 0, 1, 2, 3, 2, 3, 4, 5, 0]))


def test_map_overlap_1d_single_chunk():
x = np.arange(6)
a = xp.asarray(x, chunks=(6,))

b = cubed.map_overlap(
lambda x: x,
a,
dtype=a.dtype,
chunks=((8,),),
depth=1,
boundary=0,
trim=False,
)

assert_array_equal(b.compute(), np.array([0, 0, 1, 2, 3, 4, 5, 0]))


def test_map_overlap_2d():
x = np.arange(36).reshape((6, 6))
a = xp.asarray(x, chunks=(3, 3))
Expand Down
Loading