Skip to content

Commit

Permalink
Enabled ... for atoms, orbitals arguments
Browse files Browse the repository at this point in the history
This seems a bit more natural than None.

Signed-off-by: Nick Papior <nickpapior@gmail.com>
  • Loading branch information
zerothi committed Dec 5, 2024
1 parent a106df4 commit fbf8905
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ we hit release version 1.0.0.
sisl.geom.graphene

- added Nambu spin configuration, this is still experimental
- enabled `...` when extracting slices of MD steps in siesta output
files.
Here it is the same as `:`. But it also allows
inline arguments: `read_scf(imd=...)` where `imd=:` is not
allowed, partly fixes #835
- enabled `...` for `atoms=` arguments. Selects all atoms.

### Fixed
- `projection` arguments of several functions has been streamlined
Expand All @@ -29,10 +35,6 @@ we hit release version 1.0.0.
with *many* edges in the sparse matrix, but a perf. hit for very
small TB matrices.
- dtype removed from `Spin` class
- enabled `...` when extracting slices of MD steps.
Here it is the same as `:`. But it also allows
inline arguments: `read_scf(imd=...)` where `imd=:` is not
allowed, partly fixes #835


## [0.15.2] - 2024-11-06
Expand Down
5 changes: 5 additions & 0 deletions src/sisl/_core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,12 @@ def _sanitize_atoms(self, atoms) -> ndarray:
- name -> self._names[name]
- `Atom` -> self.atoms.index(atom)
- range/list/ndarray -> ndarray
- `...` -> ndarray
"""
if atoms is None:
return np.arange(self.na)
elif atoms is Ellipsis:
return np.arange(self.na)
atoms = _a.asarray(atoms)
if atoms.size == 0:
return _a.asarrayl([])
Expand Down Expand Up @@ -452,6 +455,8 @@ def _sanitize_orbs(self, orbitals) -> ndarray:
"""
if orbitals is None:
return np.arange(self.no)
elif orbitals is Ellipsis:
return np.arange(self.no)
orbitals = _a.asarray(orbitals)
if orbitals.size == 0:
return _a.asarrayl([])
Expand Down
5 changes: 5 additions & 0 deletions src/sisl/_core/tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,11 @@ def test_geometry_sort_int():
assert np.all(np.diff(bi.fxyz[ix, 1] * bi.lattice.length[i]) <= atol)


def test_geometry_ellipsis():
gr = sisl_geom.graphene()
assert np.allclose(gr.axyz(...), gr.axyz(None))


def test_geometry_sort_atom():
bi = sisl_geom.bilayer().tile(2, 0).repeat(2, 1)

Expand Down
2 changes: 2 additions & 0 deletions src/sisl/typing/_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"GenericCategory",
"Shape",
bool, # for all or none
Ellipsis, # for all atoms
None, # typically used to default for all
]
"""Indexing atoms via various construct methods"""
Expand All @@ -91,6 +92,7 @@
"AtomCategory", # gets expended to orbitals on the atoms
"Shape",
bool,
Ellipsis, # for all orbitals
None,
]
"""Indexing orbitals via various construct methods"""

0 comments on commit fbf8905

Please sign in to comment.