Skip to content

Commit 72ce65c

Browse files
committed
For MuliFab indexing, () means all cells in all dimension, valid and ghost
1 parent d9e7fd0 commit 72ce65c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/amrex/extensions/MultiFab.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ def _process_index(self, index):
316316
# If only one slice or integer passed in, it was not wrapped in a tuple
317317
index = [index]
318318
elif isinstance(index, tuple):
319-
if len(index) == 0:
320-
# The empty tuple specifies all valid and ghost cells
321-
index = [index]
319+
if len(index) == 0:
320+
# The empty tuple specifies all valid and ghost cells for all axis
321+
index = dims*[index]
322322
else:
323323
index = list(index)
324324
for i in range(len(index)):

tests/test_multifab.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ def test_mfab_numpy(mfab):
7777
# Config = sim.extension.Config
7878

7979
# Using global indexing
80-
# Set all valid cells (and internal ghost cells)
80+
# Set all cells, valid and ghost cells, using the empty tuple
81+
mfab[()] = np.pi
82+
83+
# Set all valid cells (and ghost cells overlapping valid cells), using the Ellipsis
8184
mfab[...] = 42.0
8285

8386
# Set a range of cells. Indices are in Fortran order.
@@ -87,7 +90,7 @@ def test_mfab_numpy(mfab):
8790
# Third dimension, sets all valid and ghost cells
8891
# - The empty tuple is used to specify the range to include all valid and ghost cells.
8992
# Components dimension, sets first component.
90-
mfab[-1j:2j, :, (), 0] = 42.0
93+
mfab[-1j:2j, :, (), 0] = 37.0
9194

9295
# Get a range of cells
9396
# Get the data along the valid cells in the first dimension (gathering data across blocks

0 commit comments

Comments
 (0)