diff --git a/sisl/grid.py b/sisl/grid.py index 0e88fd186f..f18c73e2f2 100644 --- a/sisl/grid.py +++ b/sisl/grid.py @@ -397,7 +397,7 @@ def copy(self, dtype=None): d['dtype'] = dtype grid = self.__class__([1] * 3, bc=np.copy(self.bc), **d) # This also ensures the shape is copied! - grid.grid = self.grid.copy() + grid.grid = self.grid.astype(dtype=d['dtype']) return grid def swapaxes(self, a, b): diff --git a/sisl/tests/test_grid.py b/sisl/tests/test_grid.py index ad424ee327..f5ab127af5 100644 --- a/sisl/tests/test_grid.py +++ b/sisl/tests/test_grid.py @@ -72,6 +72,8 @@ def test_dtype(self, setup): def test_copy(self, setup): assert setup.g.copy() == setup.g assert not setup.g.copy() != setup.g + gc = setup.g.copy(dtype=np.complex128) + assert gc.dtype == np.complex128 def test_add1(self, setup): g = setup.g + setup.g