Skip to content

Commit

Permalink
CI: add single mpi sparse test
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Jul 1, 2024
1 parent 1148087 commit da295c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions devito/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,12 @@ def __array_finalize__(self, obj):
decomposition.append(dec.reshape(i))
self._decomposition = tuple(decomposition)
self._allocator = obj._allocator
self._is_distributed = any(i is not None for i in self._decomposition)
decomp = any(i is not None for i in self._decomposition)
self._is_distributed = decomp and obj._is_distributed
else:
self._distributor = obj._distributor
self._allocator = obj._allocator
self._is_distributed = obj._is_distributed
if self.ndim == obj.ndim:
# E.g., from a ufunc, such as `np.add`
self._modulo = obj._modulo
Expand All @@ -142,7 +144,6 @@ def __array_finalize__(self, obj):
# E.g., from a reduction operation such as `np.mean` or `np.all`
self._modulo = tuple(False for i in range(self.ndim))
self._decomposition = (None,)*self.ndim
self._is_distributed = any(i is not None for i in self._decomposition)

@property
def _local(self):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ def test_indexing_into_sparse(self):
sf.data[1:-1, 0] = np.arange(8)
assert np.all(sf.data[1:-1, 0] == np.arange(8))

@pytest.mark.parallel(mode=1)
def test_indexing_into_sparse_subfunc_singlempi(self, mode):
grid = Grid(shape=(4, 4))
s = SparseFunction(name='sf', grid=grid, npoint=1)
coords = np.random.rand(*s.coordinates.data.shape)
s.coordinates.data[:] = coords

s.coordinates.data[-1, :] = s.coordinates.data[-1, :] / 2

assert np.allclose(s.coordinates.data[-1, :], coords[-1, :] / 2)


class TestLocDataIDX:
"""
Expand Down

0 comments on commit da295c0

Please sign in to comment.