Skip to content

Commit

Permalink
Fix map_overlap in case of single chunk in overlap dimension (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite authored May 21, 2024
1 parent 447421e commit 3fc134c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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

0 comments on commit 3fc134c

Please sign in to comment.