Skip to content

Commit

Permalink
More exhaustive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frostedoyster committed Jan 31, 2024
1 parent b4a5221 commit 4a7651c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/cli/test_train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@ def test_train_explicit_validation_test(monkeypatch, tmp_path, output):
RESOURCES_PATH / "options_explicit_valid_test.yaml",
"options_explicit_valid_test.yaml",
)
shutil.copy(
RESOURCES_PATH / "options_explicit_valid.yaml",
"options_explicit_valid.yaml",
)
shutil.copy(
RESOURCES_PATH / "options_explicit_test.yaml",
"options_explicit_test.yaml",
)

structures = ase.io.read("qm9_reduced_100.xyz", ":")
ase.io.write("train.xyz", structures[:50])
ase.io.write("valid.xyz", structures[50:80])
ase.io.write("test.xyz", structures[80:])

command = ["metatensor-models", "train", "options_explicit_valid_test.yaml"]
command = ["metatensor-models", "train", "options_explicit_valid.yaml"]
command = ["metatensor-models", "train", "options_explicit_test.yaml"]

if output is not None:
command += ["-o", output]
Expand Down
25 changes: 25 additions & 0 deletions tests/resources/options_explicit_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defaults:
- architecture: soap_bpnn # architecture used to train the model
- _self_

architecture:
training:
batch_size: 2
num_epochs: 1

# Section defining the parameters for structure and target data
training_set:
structures:
read_from: "train.xyz"
targets:
energy:
key: "U0"

validation_set: 0.1

test_set:
structures:
read_from: "test.xyz"
targets:
energy:
key: "U0"
25 changes: 25 additions & 0 deletions tests/resources/options_explicit_valid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defaults:
- architecture: soap_bpnn # architecture used to train the model
- _self_

architecture:
training:
batch_size: 2
num_epochs: 1

# Section defining the parameters for structure and target data
training_set:
structures:
read_from: "train.xyz"
targets:
energy:
key: "U0"

validation_set:
structures:
read_from: "valid.xyz"
targets:
energy:
key: "U0"

test_set: 0.1

0 comments on commit 4a7651c

Please sign in to comment.