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 case when only empty tuple is passed in #387

Merged
Merged
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
20 changes: 13 additions & 7 deletions src/amrex/extensions/MultiFab.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,19 @@ 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
Loading