diff --git a/devito/types/sparse.py b/devito/types/sparse.py index f7f40fcaea..5865de2d86 100644 --- a/devito/types/sparse.py +++ b/devito/types/sparse.py @@ -662,7 +662,7 @@ def _arg_values(self, **kwargs): else: # We've been provided a pure-data replacement (array) values = {} - for k, v in self._dist_scatter(new).items(): + for k, v in self._dist_scatter(data=new).items(): values[k.name] = v for i, s in zip(k.indices, v.shape): size = s - sum(k._size_nodomain[i]) @@ -859,7 +859,7 @@ def __init_finalize__(self, *args, **kwargs): super().__init_finalize__(*args, **kwargs) # Set up sparse point coordinates - keys = ('coordinates','coordinates_data') + keys = ('coordinates', 'coordinates_data') self._coordinates = self.__subfunc_setup__('coords', keys, **kwargs) self._dist_origin = {self._coordinates: self.grid.origin_offset} diff --git a/tests/test_rebuild.py b/tests/test_rebuild.py index 5498d819a7..79b2765a30 100644 --- a/tests/test_rebuild.py +++ b/tests/test_rebuild.py @@ -1,8 +1,8 @@ import numpy as np import pytest -from devito import Dimension, Function -from devito.types import StencilDimension +from devito import Dimension, Function, Grid +from devito.types import StencilDimension, SparseFunction, PrecomputedSparseFunction from devito.data.allocators import DataReference @@ -65,3 +65,19 @@ def test_stencil_dimension_borked(self): # TODO: Look into Symbol._cache_key and the way the key is generated assert sd0 is sd1 + + +class TestSparseFunction: + + @pytest.mark.parametrize('sfunc', [SparseFunction, PrecomputedSparseFunction]) + def test_none_subfunc(self, sfunc): + grid = Grid((4, 4)) + coords = np.zeros((5, 2)) + + s = sfunc(name='s', grid=grid, npoint=5, coordinates=coords, r=1) + + assert s.coordinates is not None + + # Explicity set coordinates to None + sr = s._rebuild(function=None, initializer=None, coordinates=None) + assert sr.coordinates is None