Skip to content

Commit

Permalink
bugfix: grid.copy did not allow change of dtype
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrederiksen authored and zerothi committed May 24, 2022
1 parent ee9a1ba commit 2d976d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sisl/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions sisl/tests/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d976d3

Please sign in to comment.