Skip to content

Commit e91e4ca

Browse files
committed
Ask the model whether it has an uncertainty
The list of models with uncertainty estimates is gone, so the errors of the force and stress ensembles now say what the documentation says, and the calculator is asked whether the model provides an uncertainty at all.
1 parent f7fbc4c commit e91e4ca

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/upet/calculator.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,8 @@ def get_energy_ensemble(
374374
key = self._energy_ensemble_key
375375
if key is None:
376376
raise NotImplementedError(
377-
"Energy ensemble is not available for the selected model. For "
378-
"uncertainty estimates, please use one of the following models: "
379-
f"{UPET_UQ_SUPPORTED_MODELS}"
377+
"Energy ensemble is not available for the selected model. The "
378+
"documentation lists the models providing uncertainty estimates."
380379
)
381380
return self._run_uq(atoms=atoms, per_atom=per_atom, key=key)
382381

@@ -396,11 +395,11 @@ def _run_forces_stress_uq(
396395
assert compute_forces or compute_stress
397396

398397
calc = self._base_calculator
399-
if not calc._calculate_uncertainty:
398+
if not self.supports_uncertainty:
400399
raise NotImplementedError(
401-
"Forces/stress uncertainty and ensemble are not available for the "
402-
"selected model. For uncertainty estimates, please use one of the "
403-
f"following models: {UPET_UQ_SUPPORTED_MODELS}"
400+
"Forces/stress uncertainty and ensemble are not available for "
401+
"the selected model. The documentation lists the models "
402+
"providing uncertainty estimates."
404403
)
405404

406405
atoms = self._resolve_atoms(atoms)

tests/upet/test_uncertainty_quantification.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ def test_forces_stress_uncertainty_quantification(model_name):
6262
model=model_name,
6363
version=version,
6464
)
65-
if f"{model_name}-v{version}" not in UPET_UQ_SUPPORTED_MODELS:
65+
if not calc.supports_uncertainty:
6666
message = (
67-
"Forces/stress uncertainty and ensemble are not available for the "
68-
"selected model. For uncertainty estimates, please use one of the "
69-
f"following models: {UPET_UQ_SUPPORTED_MODELS}"
67+
"Forces/stress uncertainty and ensemble are not available for "
68+
"the selected model. The documentation lists the models "
69+
"providing uncertainty estimates."
7070
)
7171
with pytest.raises(NotImplementedError, match=f"^{re.escape(message)}$"):
7272
calc.get_forces_uncertainty(atoms)

0 commit comments

Comments
 (0)