From b51d804a0f399da58bfa3c547dc0d02c42f32102 Mon Sep 17 00:00:00 2001 From: gelzinyte Date: Wed, 16 Jul 2025 15:28:26 +0200 Subject: [PATCH 1/2] switch from calc.get_property to calc.results.get --- wfl/utils/save_calc_results.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/wfl/utils/save_calc_results.py b/wfl/utils/save_calc_results.py index e123b306..0e124e96 100644 --- a/wfl/utils/save_calc_results.py +++ b/wfl/utils/save_calc_results.py @@ -60,20 +60,14 @@ def save_calc_results(atoms, *, prefix, properties): if prefix + p in atoms.arrays: del atoms.arrays[prefix + p] - # Make note of implemented properties, if applicable - if isinstance(atoms.calc, SinglePointCalculator): - calc_implemented_properties=None - else: - calc_implemented_properties=atoms.calc.implemented_properties - # copy per-config and per-atom results config_results = {} atoms_results = {} for prop_name in properties: - # Sometimes a property is in `calc.results`, but not in `calc.implemented_properties` - # and `calc.get_property` fails later. Skip those. - if calc_implemented_properties is not None and prop_name not in calc_implemented_properties: - continue + if prop_name not in atoms.calc.results: + from ase.calculators.calculator import PropertyNotPresent + raise PropertyNotPresent(f"{prop_name} is one of the calculated properties " + f"({atoms.calc.results.keys()}).") if prop_name == 'energy': try: config_results['energy'] = atoms.get_potential_energy(force_consistent=True) @@ -81,9 +75,9 @@ def save_calc_results(atoms, *, prefix, properties): config_results['energy'] = atoms.get_potential_energy() continue if prop_name in per_config_properties: - config_results[prop_name] = atoms.calc.get_property(prop_name, allow_calculation=False) + config_results[prop_name] = atoms.calc.results.get(prop_name) if prop_name in per_atom_properties: - atoms_results[prop_name] = atoms.calc.get_property(prop_name, allow_calculation=False) + atoms_results[prop_name] = atoms.calc.results.get(prop_name) try: if prefix is not None: config_results['converged'] = atoms.calc.converged From 2c95d8ec90c5c323c281a6109a462996bfd66413 Mon Sep 17 00:00:00 2001 From: gelzinyte Date: Thu, 17 Jul 2025 15:33:01 +0200 Subject: [PATCH 2/2] typo --- wfl/utils/save_calc_results.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wfl/utils/save_calc_results.py b/wfl/utils/save_calc_results.py index 0e124e96..91252154 100644 --- a/wfl/utils/save_calc_results.py +++ b/wfl/utils/save_calc_results.py @@ -66,7 +66,7 @@ def save_calc_results(atoms, *, prefix, properties): for prop_name in properties: if prop_name not in atoms.calc.results: from ase.calculators.calculator import PropertyNotPresent - raise PropertyNotPresent(f"{prop_name} is one of the calculated properties " + raise PropertyNotPresent(f"{prop_name} is not one of the calculated properties " f"({atoms.calc.results.keys()}).") if prop_name == 'energy': try: