Skip to content

Commit 14559fb

Browse files
committed
basic/ex05: skip if total_energy not found
We do this in test/workflow_test.py, so seems sensible to do it here as well.
1 parent 4efe7da commit 14559fb

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

examples/basic/ex05_run_predictions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from importlib.util import find_spec
23

34
from ase.io import read
45
import mala
@@ -39,7 +40,11 @@
3940
ldos_calculator: mala.LDOS = predictor.target_calculator
4041
ldos_calculator.read_from_array(ldos)
4142
printout("Predicted band energy: ", ldos_calculator.band_energy)
43+
4244
# If the total energy module is installed, the total energy can also be
4345
# calculated.
44-
# parameters.targets.pseudopotential_path = data_path
45-
# printout("Predicted total energy", ldos_calculator.total_energy)
46+
if find_spec("total_energy"):
47+
parameters.targets.pseudopotential_path = data_path
48+
printout("Predicted total energy", ldos_calculator.total_energy)
49+
else:
50+
print("total_energy module not found, skipping total energy calculation")

0 commit comments

Comments
 (0)