Skip to content

Commit ad47584

Browse files
committed
mnt: removed cell argument in Geometry.sub
Users should do geometry.set_supercell for clarity. The argument was not present in remove which made them disjoint.
1 parent 25564ae commit ad47584

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ we hit release version 1.0.0.
5353
- fixed hpc parameters #403
5454

5555
### Changed
56+
- removed cell argument in `Geometry.sub`
5657
- removed `Sile.exist`, refer to `Sile.file` which always will be a `pathlib.Path` instance
5758
- `berry_phase` now uses the gauge=R convention, the code became much simpler
5859
- `BrillouinZone.parametrize` function changed interface to allow more dimensions

sisl/atom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ def __getitem__(self, key):
11461146
if not orbs:
11471147
return None
11481148
return orbs if len(orbs) != 1 else orbs[0]
1149-
return (self.orbitals[o] for o in key)
1149+
return [self.orbitals[o] for o in key]
11501150

11511151
def maxR(self):
11521152
""" Return the maximum range of orbitals. """

sisl/geometry.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ def optimize_nsc(self, axis=None, R=None):
16971697

16981698
return nsc
16991699

1700-
def sub(self, atoms, cell=None):
1700+
def sub(self, atoms):
17011701
""" Create a new `Geometry` with a subset of this `Geometry`
17021702
17031703
Indices passed *MUST* be unique.
@@ -1708,20 +1708,14 @@ def sub(self, atoms, cell=None):
17081708
----------
17091709
atoms : int or array_like
17101710
indices/boolean of all atoms to be removed
1711-
cell : array_like or SuperCell, optional
1712-
the new associated cell of the geometry (defaults to the same cell)
17131711
17141712
See Also
17151713
--------
17161714
SuperCell.fit : update the supercell according to a reference supercell
17171715
remove : the negative of this routine, i.e. remove a subset of atoms
17181716
"""
17191717
atoms = self.sc2uc(atoms)
1720-
if cell is None:
1721-
return self.__class__(self.xyz[atoms, :],
1722-
atoms=self.atoms.sub(atoms), sc=self.sc.copy())
1723-
return self.__class__(self.xyz[atoms, :],
1724-
atoms=self.atoms.sub(atoms), sc=cell)
1718+
return self.__class__(self.xyz[atoms, :], atoms=self.atoms.sub(atoms), sc=self.sc.copy())
17251719

17261720
def sub_orbital(self, atoms, orbitals):
17271721
r""" Retain only a subset of the orbitals on `atoms` according to `orbitals`
@@ -1965,7 +1959,8 @@ def cut(self, seps, axis, seg=0, rtol=1e-4, atol=1e-4):
19651959
# List of atoms
19661960
n = self.na // seps
19671961
off = n * lseg
1968-
new = self.sub(_a.arangei(off, off + n), cell=sc)
1962+
new = self.sub(_a.arangei(off, off + n))
1963+
new.set_supercell(sc)
19691964
if not np.allclose(new.tile(seps, axis).xyz, self.xyz, rtol=rtol, atol=atol):
19701965
st = 'The cut structure cannot be re-created by tiling'
19711966
st += '\nThe tolerance between the coordinates can be altered using rtol, atol'

0 commit comments

Comments
 (0)