Skip to content

Commit

Permalink
Special error message for force/virial/stress targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Sep 25, 2024
1 parent a6f4da6 commit 08d11ad
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/metatrain/utils/data/readers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,16 @@ def read_targets(

is_standard_target = target_key in standard_outputs_list
if not is_standard_target and not target_key.startswith("mtt::"):
raise ValueError(
f"Target name ({target_key}) must either be one of "
f"{standard_outputs_list} or start with `mtt::`."
)
if target_key.lower() in ["force", "forces", "virial", "stress"]:
raise ValueError(

Check warning on line 197 in src/metatrain/utils/data/readers/readers.py

View check run for this annotation

Codecov / codecov/patch

src/metatrain/utils/data/readers/readers.py#L197

Added line #L197 was not covered by tests
f"{target_key!r} should not be it's own top-level target, "
"but rather a sub-section of the 'energy' target"
)
else:
raise ValueError(
f"Target name ({target_key}) must either be one of "
f"{standard_outputs_list} or start with `mtt::`."
)

if target["quantity"] == "energy":
blocks = read_energy(
Expand Down

0 comments on commit 08d11ad

Please sign in to comment.