Skip to content

Commit

Permalink
data, test_data: Minor tidying.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhodrin committed Sep 16, 2020
1 parent 4ba6cb3 commit af326c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions devito/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ def __str__(self):
@_check_idx
def __getitem__(self, glb_idx, comm_type, gather_rank=None):
loc_idx = self._index_glb_to_loc(glb_idx)
gather = True if isinstance(gather_rank, int) else False
if comm_type is index_by_index or gather:
is_gather = True if isinstance(gather_rank, int) else False
if comm_type is index_by_index or is_gather:
# Retrieve the pertinent local data prior to mpi send/receive operations
data_idx = loc_data_idx(loc_idx)
self._index_stash = flip_idx(glb_idx, self._decomposition)
Expand All @@ -197,7 +197,7 @@ def __getitem__(self, glb_idx, comm_type, gather_rank=None):
self._distributor.all_coords, comm)

it = np.nditer(owners, flags=['refs_ok', 'multi_index'])
if not gather:
if not is_gather:
retval = Data(local_val.shape, local_val.dtype.type,
decomposition=local_val._decomposition,
modulo=(False,)*len(local_val.shape))
Expand All @@ -208,11 +208,11 @@ def __getitem__(self, glb_idx, comm_type, gather_rank=None):
# Iterate over each element of data
while not it.finished:
index = it.multi_index
send_rank = gather_rank if gather else send[index]
send_rank = gather_rank if is_gather else send[index]
if rank == owners[index] and rank == send_rank:
# Current index and destination index are on the same rank
loc_ind = local_si[index]
if gather:
if is_gather:
loc_ind = local_si[index]
retval[global_si[index]] = local_val.data[loc_ind]
else:
Expand All @@ -222,7 +222,7 @@ def __getitem__(self, glb_idx, comm_type, gather_rank=None):
# Current index is on this rank and hence need to send
# the data to the appropriate rank
loc_ind = local_si[index]
send_rank = gather_rank if gather else send[index]
send_rank = gather_rank if is_gather else send[index]
send_ind = global_si[index]
send_val = local_val.data[loc_ind]
reqs = comm.isend([send_ind, send_val], dest=send_rank)
Expand All @@ -231,7 +231,7 @@ def __getitem__(self, glb_idx, comm_type, gather_rank=None):
# Current rank is required to receive data from this index
recval = comm.irecv(source=owners[index])
local_dat = recval.wait()
if gather:
if is_gather:
retval[local_dat[0]] = local_dat[1]
else:
loc_ind = local_si[local_dat[0]]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ def test_sliced_gather_2D(self, start, stop, step):
(1, 8, 3),
((0, 4, 4), None, (2, 1, 1))])
def test_sliced_gather_3D(self, start, stop, step):
""" Test gather for various 2D slices."""
""" Test gather for various 3D slices."""
grid = Grid(shape=(10, 10, 10), extent=(9, 9, 9))
f = Function(name='f', grid=grid, dtype=np.int32)
dat = np.arange(1000).reshape(grid.shape)
Expand Down

0 comments on commit af326c3

Please sign in to comment.