Skip to content

Commit 526206a

Browse files
committed
Fix case when only empty tuple is passed in
1 parent 1aa1db3 commit 526206a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/amrex/extensions/MultiFab.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,17 @@ def _process_index(self, index):
314314
# If only one slice or integer passed in, it was not wrapped in a tuple
315315
index = [index]
316316
elif isinstance(index, tuple):
317-
index = list(index)
318-
for i in range(len(index)):
319-
if index[i] == Ellipsis:
320-
index = (
321-
index[:i] + (dims + 2 - len(index)) * [slice(None)] + index[i + 1 :]
322-
)
323-
break
317+
if len(index) == 0:
318+
# The empty tuple specifies all valid and ghost cells
319+
index = [index]
320+
else:
321+
index = list(index)
322+
for i in range(len(index)):
323+
if index[i] == Ellipsis:
324+
index = (
325+
index[:i] + (dims + 2 - len(index)) * [slice(None)] + index[i + 1 :]
326+
)
327+
break
324328
else:
325329
raise Exception("MultiFab.__getitem__: unexpected index type")
326330

0 commit comments

Comments
 (0)