Skip to content

Commit 917f326

Browse files
Fix case when only empty tuple is passed in (#387)
One more fix for the global indexing of MultiFabs. I hadn't taken care of the case when only the empty tuple is passed in (for example for 1D). This PR fixes this case. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 1aa1db3 commit 917f326

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/amrex/extensions/MultiFab.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,19 @@ 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]
326+
+ (dims + 2 - len(index)) * [slice(None)]
327+
+ index[i + 1 :]
328+
)
329+
break
324330
else:
325331
raise Exception("MultiFab.__getitem__: unexpected index type")
326332

0 commit comments

Comments
 (0)