diff --git a/janus_core/processing/observables.py b/janus_core/processing/observables.py index 07a0626f..f2a12f8b 100644 --- a/janus_core/processing/observables.py +++ b/janus_core/processing/observables.py @@ -138,9 +138,8 @@ def _set_components(self, components: list[str]): ValueError If any component is invalid. """ - for component in components: + for component in self.allowed_components.keys() - components.keys(): if component not in self.allowed_components: - component_names = list(self._components.keys()) raise ValueError( f"'{component}' invalid, must be '{', '.join(component_names)}'" ) @@ -267,10 +266,7 @@ def __init__( Observable.__init__(self, len(components)) - if atoms_slice: - self.atoms_slice = atoms_slice - else: - self.atoms_slice = slice(0, None, 1) + self.atoms_slice = atoms_slice if atoms_slice else slice(0, None, 1) def __call__(self, atoms: Atoms) -> list[float]: """