Skip to content
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

Fix the bug in np.append test on empty input array and non-empty scalars #365

Merged
merged 3 commits into from
May 18, 2022
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
17 changes: 7 additions & 10 deletions cunumeric/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ def _block_collect_slices(arr, cur_depth, depth):
)
common_shape = common_info.shape
# the initial slices for each arr on arr.shape[-1]
out_shape, slices = _collect_outshape_slices(
out_shape, slices, arrays = _collect_outshape_slices(
arrays, common_shape, axis=-1 + len(common_shape)
)

Expand All @@ -1361,14 +1361,12 @@ def _collect_outshape_slices(inputs, common_shape, axis):
slices = []
offset = 0
# collect slices for arrays in `inputs`
inputs = list(inp for inp in inputs if inp.size > 0)
for inp in inputs:
if inp.size > 0:
slices.append(
(slice(offset, offset + inp.shape[axis]),) + post_idx
)
offset += inp.shape[axis]
slices.append((slice(offset, offset + inp.shape[axis]),) + post_idx)
offset += inp.shape[axis]

return out_shape, slices
return out_shape, slices, inputs


def _concatenate(
Expand All @@ -1381,7 +1379,7 @@ def _concatenate(
):
if axis < 0:
axis += len(common_info.shape)
out_shape, slices = _collect_outshape_slices(
out_shape, slices, inputs = _collect_outshape_slices(
inputs, common_info.shape, axis
)

Expand All @@ -1401,8 +1399,7 @@ def _concatenate(
out_array = out

for dest, src in zip(slices, inputs):
if src.size > 0:
out_array[(Ellipsis,) + dest] = src
out_array[(Ellipsis,) + dest] = src

return out_array

Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def _check(a, b, depth, sizes):
SIZE_CASES = [
[(0,), (0,)], # empty arrays
[(1,), (1,)], # singlton arrays
[(0,), (10,)], # empty and scalars
[(DIM, 1), (DIM, DIM)], # 1D and 2D arrays
[(DIM, 1), (DIM, 1), (DIM, DIM)], # 3 arrays in the inner-most list
]
Expand Down