Skip to content

Commit

Permalink
Merge pull request #353 from arosen93/molecule
Browse files Browse the repository at this point in the history
Add missing molecule field to cclib TaskDocument
  • Loading branch information
utf committed May 23, 2023
2 parents 07073ca + 96fa4c7 commit 236d471
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/atomate2/common/schemas/cclib.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def from_logfile(
initial_molecule = molecules[0]
final_molecule = molecules[-1]
attributes["molecule_initial"] = initial_molecule
attributes["molecule_final"] = final_molecule
if store_trajectory:
attributes["trajectory"] = molecules

Expand Down Expand Up @@ -249,6 +248,7 @@ def from_logfile(
attributes=attributes,
metadata=metadata,
)
doc.molecule = final_molecule
doc = doc.copy(update=additional_fields)
return doc

Expand Down
6 changes: 2 additions & 4 deletions tests/common/schemas/test_cclib.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def test_cclib_taskdoc(test_dir):
assert doc.get("metadata", None) is not None
assert doc["metadata"]["success"] is True
assert doc["attributes"]["molecule_initial"][0].coords == pytest.approx([0, 0, 0])
assert doc["attributes"]["molecule_final"][0].coords == pytest.approx(
[0.397382, 0.0, 0.0]
)
assert doc["molecule"][0].coords == pytest.approx([0.397382, 0.0, 0.0])
assert doc["last_updated"] is not None
assert doc["attributes"]["homo_energies"] == pytest.approx(
[-7.054007346511501, -11.618445074798501]
Expand Down Expand Up @@ -85,7 +83,7 @@ def test_cclib_taskdoc(test_dir):
doc = TaskDocument.from_logfile(p, ".log", store_trajectory=True).dict()
assert len(doc["attributes"]["trajectory"]) == 7
assert doc["attributes"]["trajectory"][0] == doc["attributes"]["molecule_initial"]
assert doc["attributes"]["trajectory"][-1] == doc["attributes"]["molecule_final"]
assert doc["attributes"]["trajectory"][-1] == doc["molecule"]

# Make sure additional fields can be stored
doc = TaskDocument.from_logfile(p, ".log", additional_fields={"test": "hi"})
Expand Down

0 comments on commit 236d471

Please sign in to comment.