From d1d7e4718d0c4323ff2923f209420ad77ba5410f Mon Sep 17 00:00:00 2001 From: Harvey Devereux Date: Fri, 8 Nov 2024 15:31:51 +0000 Subject: [PATCH] Check atoms is Atoms, clearer exception --- janus_core/processing/observables.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/janus_core/processing/observables.py b/janus_core/processing/observables.py index 00b1de97..2d8d9083 100644 --- a/janus_core/processing/observables.py +++ b/janus_core/processing/observables.py @@ -180,7 +180,14 @@ def __call__(self, atoms: Atoms) -> list[float]: ------- list[float] The stress components in GPa units. + + Raises + ------ + ValueError + If atoms is not an Atoms object. """ + if not isinstance(atoms, Atoms): + raise ValueError("atoms should be an Atoms object") sliced_atoms = atoms[self.atoms_slice] # must be re-attached after slicing for get_stress sliced_atoms.calc = atoms.calc