Skip to content

Commit

Permalink
Fix case when only empty tuple is passed in
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Oct 29, 2024
1 parent 1aa1db3 commit 526206a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/amrex/extensions/MultiFab.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,17 @@ def _process_index(self, index):
# If only one slice or integer passed in, it was not wrapped in a tuple
index = [index]
elif isinstance(index, tuple):
index = list(index)
for i in range(len(index)):
if index[i] == Ellipsis:
index = (
index[:i] + (dims + 2 - len(index)) * [slice(None)] + index[i + 1 :]
)
break
if len(index) == 0:
# The empty tuple specifies all valid and ghost cells
index = [index]
else:
index = list(index)
for i in range(len(index)):
if index[i] == Ellipsis:
index = (
index[:i] + (dims + 2 - len(index)) * [slice(None)] + index[i + 1 :]
)
break
else:
raise Exception("MultiFab.__getitem__: unexpected index type")

Expand Down

0 comments on commit 526206a

Please sign in to comment.