-
-
Notifications
You must be signed in to change notification settings - Fork 65
Improve Atoms.index usability #954
Copy link
Copy link
Closed
Description
Currently, geom.atoms.index("H") raises a KeyError("Could not find atom in the list of atoms.") if no atoms of that species exist. This makes workflows like subsetting by element more cumbersome, since users must wrap calls in try/except.
It would be more intuitive if:
Atoms.index(symbol)returned an empty array[]when no atoms are found.Atoms.indexaccepted multiple species in one call, e.g.:
geom.atoms.index("H", "C")
geom.atoms.index(["H", "C"])returning the combined indices.
Both changes would simplify common tasks like extracting subsets (CH, CN, etc.) while remaining backwards-compatible.
Happy to open a PR if this direction is welcome.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels