Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/test_mlip_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
("mace_mp", "cpu", {"model": "small"}),
("mace_mp", "cpu", {"model": MACE_MP_PATH}),
("mace_off", "cpu", {}),
("mace_off", "cpu", {"model": "small"}),
("mace_off", "cpu", {"model": "medium"}),
("mace_off", "cpu", {"model": MACE_OFF_PATH}),
("mace_omol", "cpu", {}),
("mace_omol", "cpu", {"model": "extra_large"}),
Expand Down Expand Up @@ -118,6 +118,9 @@ def test_mlips(arch, device, kwargs):
except URLError as err:
if "Connection timed out" in err.reason:
pytest.skip("Model download failed")
except RuntimeError as err:
if "Model download failed" in str(err):
pytest.skip("Model download failed")
raise err


Expand Down
49 changes: 29 additions & 20 deletions tests/test_single_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def test_extras(arch, device, expected_energy, struct, kwargs):
if "Connection timed out" in err.reason:
pytest.skip("Model download failed")
raise err
except RuntimeError as err:
if "Model download failed" in str(err):
pytest.skip("Model download failed")
raise err


def test_single_point_none():
Expand Down Expand Up @@ -467,28 +471,33 @@ def test_dispersion(arch, kwargs, pred):
skip_extras(arch)
pytest.importorskip("torch_dftd")

data_path = DATA_PATH / "benzene.xyz"
sp_no_d3 = SinglePoint(
struct=data_path,
arch=arch,
properties="energy",
calc_kwargs={"dispersion": False},
)
assert not isinstance(sp_no_d3.struct.calc, SumCalculator)
no_d3_results = sp_no_d3.run()
try:
data_path = DATA_PATH / "benzene.xyz"
sp_no_d3 = SinglePoint(
struct=data_path,
arch=arch,
properties="energy",
calc_kwargs={"dispersion": False},
)
assert not isinstance(sp_no_d3.struct.calc, SumCalculator)
no_d3_results = sp_no_d3.run()

sp_d3 = SinglePoint(
struct=data_path,
arch=arch,
properties="energy",
calc_kwargs={"dispersion": True, "dispersion_kwargs": {**kwargs}},
)
assert isinstance(sp_d3.struct.calc, SumCalculator)
d3_results = sp_d3.run()
sp_d3 = SinglePoint(
struct=data_path,
arch=arch,
properties="energy",
calc_kwargs={"dispersion": True, "dispersion_kwargs": {**kwargs}},
)
assert isinstance(sp_d3.struct.calc, SumCalculator)
d3_results = sp_d3.run()

assert (d3_results["energy"] - no_d3_results["energy"]) == pytest.approx(
pred, rel=1e-5
)
assert (d3_results["energy"] - no_d3_results["energy"]) == pytest.approx(
pred, rel=1e-5
)
except RuntimeError as err:
if "Model download failed" in str(err):
pytest.skip("Model download failed")
raise err


def test_mace_mp_dispersion():
Expand Down
Loading