Skip to content

Commit

Permalink
add test_model_load()
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Oct 23, 2023
1 parent 1747180 commit 7c22ab1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,21 @@ def test_as_to_from_dict() -> None:

model_3 = CHGNet(**to_dict["model_args"])
assert model_3.todict() == to_dict


def test_model_load(capsys: pytest.CaptureFixture) -> None:
model = CHGNet.load()
assert model.version == "0.3.0"
stdout, stderr = capsys.readouterr()
assert stdout == "CHGNet initialized with 412,525 parameters\n"
assert stderr == ""

model = CHGNet.load(model_name="0.2.0")
assert model.version == "0.2.0"
stdout, stderr = capsys.readouterr()
assert stdout == "CHGNet initialized with 400,438 parameters\n"
assert stderr == ""

model_name = "0.1.0" # invalid
with pytest.raises(ValueError, match=f"Unknown {model_name=}"):
CHGNet.load(model_name=model_name)

0 comments on commit 7c22ab1

Please sign in to comment.