diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2684afc479..3f479a80e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,7 +46,7 @@ repos: - id: rst-directive-colons - id: rst-inline-touching-normal - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.3.0 + rev: v1.4.1 hooks: - id: mypy files: ^src/ @@ -55,7 +55,7 @@ repos: - types-pkg_resources==0.1.2 - types-paramiko - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 + rev: v2.2.5 hooks: - id: codespell stages: [commit, commit-msg] diff --git a/src/atomate2/common/schemas/cclib.py b/src/atomate2/common/schemas/cclib.py index a64a55fe84..8f15a12eae 100644 --- a/src/atomate2/common/schemas/cclib.py +++ b/src/atomate2/common/schemas/cclib.py @@ -5,7 +5,6 @@ from pathlib import Path from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union -import numpy as np from emmet.core.structure import MoleculeMetadata from monty.dev import requires from monty.json import jsanitize @@ -163,9 +162,9 @@ def from_logfile( cclib_obj.metadata.get("coord_type", None) == "xyz" and cclib_obj.metadata.get("coords", None) is not None ): - coords_obj = np.array(cclib_obj.metadata["coords"]) - input_species = [Element(e) for e in coords_obj[:, 0]] - input_coords = coords_obj[:, 1:].tolist() + coords_obj = cclib_obj.metadata["coords"] + input_species = [Element(row[0]) for row in coords_obj] + input_coords = [row[1:] for row in coords_obj] input_molecule = Molecule( input_species, input_coords, diff --git a/tests/common/schemas/test_cclib.py b/tests/common/schemas/test_cclib.py index a48144749d..3a0c30b179 100644 --- a/tests/common/schemas/test_cclib.py +++ b/tests/common/schemas/test_cclib.py @@ -56,11 +56,13 @@ def test_cclib_taskdoc(test_dir): assert "Could not parse" in str(e.value) # Test a population analysis - doc = TaskDocument.from_logfile(p, ".out", analysis="MBO").dict() + doc = TaskDocument.from_logfile(p, "psi_test.out", analysis="MBO").dict() assert doc["attributes"]["mbo"] is not None # Let's try with two analysis (also check case-insensitivity) - doc = TaskDocument.from_logfile(p, ".out", analysis=["mbo", "density"]).dict() + doc = TaskDocument.from_logfile( + p, "psi_test.out", analysis=["mbo", "density"] + ).dict() assert doc["attributes"]["mbo"] is not None assert doc["attributes"]["density"] is not None @@ -75,7 +77,7 @@ def test_cclib_taskdoc(test_dir): p / "psi_test.cube", "wb" ) as f_out: shutil.copyfileobj(f_in, f_out) - doc = TaskDocument.from_logfile(p, ".out", analysis=["Bader"]).dict() + doc = TaskDocument.from_logfile(p, "psi_test.out", analysis=["Bader"]).dict() os.remove(p / "psi_test.cube") assert doc["attributes"]["bader"] is not None @@ -89,6 +91,10 @@ def test_cclib_taskdoc(test_dir): doc = TaskDocument.from_logfile(p, ".log", additional_fields={"test": "hi"}) assert doc.dict()["test"] == "hi" + # Test that the dict printing works + task = TaskDocument.from_logfile(p, "orca.out") + task.dict() + # test document can be jsanitized d = jsanitize(doc, enum_values=True) diff --git a/tests/test_data/schemas/orca.out.gz b/tests/test_data/schemas/orca.out.gz new file mode 100644 index 0000000000..87dde688d8 Binary files /dev/null and b/tests/test_data/schemas/orca.out.gz differ