Skip to content

Commit

Permalink
fix result dictionary (#136)
Browse files Browse the repository at this point in the history
* Fix results dictionary

* Set read format to extxyz for singlepoint output

---------

Co-authored-by: alin elena <alin@elena.re>
  • Loading branch information
federicazanca and alinelena authored Jun 5, 2024
1 parent c55a2d4 commit 3c4d7ec
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 3 additions & 1 deletion aiida_mlip/parsers/sp_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def parse(self, **kwargs) -> int:
with self.retrieved.open(xyz_output, "rb") as handle:
self.out("xyz_output", SinglefileData(file=handle, filename=xyz_output))

content = read(Path(self.node.get_remote_workdir(), xyz_output))
content = read(
Path(self.node.get_remote_workdir(), xyz_output), format="extxyz"
)
results = convert_numpy(content.todict())
results_node = Dict(results)
self.out("results_dict", results_node)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ documentation = "https://stfc.github.io/aiida-mlip/"
[tool.poetry.dependencies]
python = "^3.9"
aiida-core = "^2.5"
ase = "^3.22.1"
ase = "^3.23.0"
voluptuous = "^0.14"
janus-core = "^v0.5.0b0"
janus-core = "^v0.6.0b0"

[tool.poetry.group.dev.dependencies]
coverage = {extras = ["toml"], version = "^7.4.1"}
Expand Down
1 change: 0 additions & 1 deletion tests/calculations/configs/config_janus.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
properties:
- "energy"
out: "results.xyz"
arch: mace_mp
2 changes: 1 addition & 1 deletion tests/calculations/test_geomopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_run_opt(model_folder, janus_code):
assert "traj_output" in result
assert "traj_file" in result
assert result["traj_output"].numsteps == 3
assert result["final_structure"].cell[0][1] == pytest.approx(2.8442048309822)
assert result["final_structure"].cell[0][1] == pytest.approx(2.8438848145858)
assert result["xyz_output"].filename == "aiida-results.xyz"


Expand Down
5 changes: 2 additions & 3 deletions tests/calculations/test_singlepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ def test_run_sp(model_folder, janus_code):

singlePointCalculation = CalculationFactory("mlip.sp")
result = run(singlePointCalculation, **inputs)

assert "results_dict" in result
obtained_res = result["results_dict"].get_dict()
assert "xyz_output" in result
assert obtained_res["info"]["energy"] == pytest.approx(-6.7575203839729)
assert obtained_res["info"]["stress"][0][0] == pytest.approx(-0.005816546985101)
assert obtained_res["info"]["mace_energy"] == pytest.approx(-6.7575203839729)
assert obtained_res["info"]["mace_stress"][0] == pytest.approx(-0.005816546985101)


def test_example(example_path):
Expand Down

0 comments on commit 3c4d7ec

Please sign in to comment.