Skip to content

Commit

Permalink
better "extras" passing in Molecule for EFP
Browse files Browse the repository at this point in the history
  • Loading branch information
loriab committed Sep 3, 2019
1 parent 7cb0fc8 commit 4b18220
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions qcelemental/models/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,9 @@ def from_data(cls,
raise TypeError("Input type not understood, please supply the 'dtype' kwarg.")

if dtype in ["string", "psi4", "psi4+", "xyz", "xyz+"]:
mol_dict = from_string(data)
assert isinstance(mol_dict, dict)
input_dict = to_schema(mol_dict["qm"], dtype=2)
molrec = from_string(data, enable_qm=True, missing_enabled_return_qm='minimal')
assert isinstance(molrec, dict)
input_dict = to_schema(molrec["qm"], dtype=2)
validate = True
elif dtype == "numpy":
data = np.asarray(data)
Expand Down
8 changes: 8 additions & 0 deletions qcelemental/molparse/to_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ def to_schema(molrec: Dict[str, Any],
if 'connectivity' in molrec:
molecule['connectivity'] = deepcopy(molrec['connectivity'])

# EFP extras
if 'fragment_files' in molrec:
molecule['extras'] = {
'fragment_files': molrec['fragment_files'],
'hint_types': molrec['hint_types'],
'geom_hints': molrec['geom_hints'],
}

if dtype == 1:
qcschema = {'schema_name': 'qcschema_input', 'schema_version': 1, 'molecule': molecule}
elif dtype == 2:
Expand Down
3 changes: 2 additions & 1 deletion qcelemental/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def test_unique_everseen(inp, expected):
@pytest.mark.parametrize("inp,expected", [
(({1:{"a":"A"},2:{"b":"B"}}, {2:{"c":"C"},3:{"d":"D"}}), {1:{"a":"A"},2:{"b":"B","c":"C"},3:{"d":"D"}}),
(({1:{"a":"A"},2:{"b":"B","c":None}}, {2:{"c":"C"},3:{"d":"D"}}), {1:{"a":"A"},2:{"b":"B","c":"C"},3:{"d":"D"}}),
(({1: [None, 1]}, {1: [2, 1],3:{"d":"D"}}), {1:[2, 1], 3:{"d":"D"}})
(({1: [None, 1]}, {1: [2, 1],3:{"d":"D"}}), {1:[2, 1], 3:{"d":"D"}}),
(({1: True, 'extras':{'aa': [True]}}, {2: None, 'extras':{'bb': 5}}), {1: True, 2: None, 'extras':{'aa': [True], 'bb':5}}),
]) # yapf: disable
def test_updatewitherror(inp, expected):
assert compare_recursive(expected, qcel.util.update_with_error(inp[0], inp[1]))
Expand Down

0 comments on commit 4b18220

Please sign in to comment.