Skip to content

Commit

Permalink
Merge branch 'materialsproject:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
naik-aakash authored Jul 1, 2023
2 parents 61298f5 + ce0a6f7 commit 3ad31f6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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]
Expand Down
7 changes: 3 additions & 4 deletions src/atomate2/common/schemas/cclib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions tests/common/schemas/test_cclib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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)

Expand Down
Binary file added tests/test_data/schemas/orca.out.gz
Binary file not shown.

0 comments on commit 3ad31f6

Please sign in to comment.