diff --git a/qcelemental/models/molecule.py b/qcelemental/models/molecule.py index 8130318e..6044fb97 100644 --- a/qcelemental/models/molecule.py +++ b/qcelemental/models/molecule.py @@ -235,7 +235,10 @@ def __init__(self, orient: bool = False, validate: Optional[bool] = None, **kwar kwargs["schema_version"] = kwargs.pop("schema_version", 2) # original_keys = set(kwargs.keys()) # revive when ready to revisit sparsity - schema = to_schema(from_schema(kwargs), dtype=kwargs["schema_version"], copy=False, np_out=True) + schema = to_schema(from_schema(kwargs, missing_enabled_return='minimal'), + dtype=kwargs["schema_version"], + copy=False, + np_out=True) kwargs["validated"] = True kwargs = {**kwargs, **schema} # Allow any extra fields @@ -724,9 +727,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) diff --git a/qcelemental/molparse/from_schema.py b/qcelemental/molparse/from_schema.py index 83202608..882d2bc1 100644 --- a/qcelemental/molparse/from_schema.py +++ b/qcelemental/molparse/from_schema.py @@ -7,7 +7,7 @@ from .from_arrays import from_arrays -def from_schema(molschema, *, verbose: int = 1) -> Dict: +def from_schema(molschema, *, missing_enabled_return: str = 'error', verbose: int = 1) -> Dict: """Construct molecule dictionary representation from non-Psi4 schema. Parameters @@ -71,7 +71,7 @@ def from_schema(molschema, *, verbose: int = 1) -> Dict: provenance=ms.get('provenance', None), connectivity=ms.get('connectivity', None), domain='qm', - #missing_enabled_return=missing_enabled_return, + missing_enabled_return=missing_enabled_return, speclabel=False, #tooclose=tooclose, #zero_ghost_fragments=zero_ghost_fragments, diff --git a/qcelemental/molparse/to_schema.py b/qcelemental/molparse/to_schema.py index 14398548..70a7db69 100644 --- a/qcelemental/molparse/to_schema.py +++ b/qcelemental/molparse/to_schema.py @@ -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: diff --git a/qcelemental/tests/test_utils.py b/qcelemental/tests/test_utils.py index 93cc38d5..12540c21 100644 --- a/qcelemental/tests/test_utils.py +++ b/qcelemental/tests/test_utils.py @@ -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]))