diff --git a/docs/source/model_result.rst b/docs/source/model_result.rst index 481433c7..23270819 100644 --- a/docs/source/model_result.rst +++ b/docs/source/model_result.rst @@ -1,27 +1,27 @@ -Result +AtomicResult ====== A Python implementation of the `MolSSI QCSchema -`_ ``Result`` object. +`_ ``AtomicResult`` object. -ResultInput +AtomicInput ----------- -.. autoclass:: qcelemental.models.ResultInput +.. autoclass:: qcelemental.models.AtomicInput -Result +AtomicResult ------ -.. autoclass:: qcelemental.models.Result +.. autoclass:: qcelemental.models.AtomicResult API --- -.. autoclass:: qcelemental.models.results.ResultProtocols +.. autoclass:: qcelemental.models.results.AtomicResultProtocols -.. autoclass:: qcelemental.models.results.ResultProperties +.. autoclass:: qcelemental.models.results.AtomicResultProperties .. autoclass:: qcelemental.models.results.WavefunctionProperties diff --git a/qcelemental/datum.py b/qcelemental/datum.py index 49b861ce..2ec7abb6 100644 --- a/qcelemental/datum.py +++ b/qcelemental/datum.py @@ -6,7 +6,6 @@ from typing import Any, Dict, Optional import numpy as np - from pydantic import BaseModel, validator diff --git a/qcelemental/models/__init__.py b/qcelemental/models/__init__.py index 24cc71c7..f2c6102c 100644 --- a/qcelemental/models/__init__.py +++ b/qcelemental/models/__init__.py @@ -12,5 +12,5 @@ from .basis import BasisSet from .common_models import ComputeError, DriverEnum, FailedOperation, Provenance from .molecule import Molecule -from .procedures import Optimization, OptimizationInput -from .results import Result, ResultInput, ResultProperties +from .procedures import Optimization, OptimizationInput, OptimizationResult +from .results import AtomicInput, AtomicResult, AtomicResultProperties, Result, ResultInput, ResultProperties diff --git a/qcelemental/models/align.py b/qcelemental/models/align.py index c71def40..00db470a 100644 --- a/qcelemental/models/align.py +++ b/qcelemental/models/align.py @@ -1,5 +1,4 @@ import numpy as np - from pydantic import validator from ..util import blockwise_contract, blockwise_expand diff --git a/qcelemental/models/basemodels.py b/qcelemental/models/basemodels.py index 7bc03ea3..6484c038 100644 --- a/qcelemental/models/basemodels.py +++ b/qcelemental/models/basemodels.py @@ -3,8 +3,8 @@ from typing import Any, Dict, Optional, Set, Union import numpy as np - from pydantic import BaseModel, BaseSettings + from qcelemental.testing import compare_recursive from qcelemental.util import deserialize, serialize from qcelemental.util.autodocs import AutoPydanticDocGenerator diff --git a/qcelemental/models/common_models.py b/qcelemental/models/common_models.py index 0a7afaaa..cd09c006 100644 --- a/qcelemental/models/common_models.py +++ b/qcelemental/models/common_models.py @@ -2,7 +2,6 @@ from typing import Any, Dict, Optional import numpy as np - from pydantic import Field from .basemodels import ProtoModel diff --git a/qcelemental/models/molecule.py b/qcelemental/models/molecule.py index a77466d9..859ea8c6 100644 --- a/qcelemental/models/molecule.py +++ b/qcelemental/models/molecule.py @@ -10,7 +10,6 @@ from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np - from pydantic import Field, constr, validator from ..molparse import from_arrays, from_schema, from_string, to_schema, to_string diff --git a/qcelemental/models/procedures.py b/qcelemental/models/procedures.py index 67b342c4..eac0dbd3 100644 --- a/qcelemental/models/procedures.py +++ b/qcelemental/models/procedures.py @@ -124,6 +124,7 @@ def _trajectory_protocol(cls, v, values): return v + def Optimization(*args, **kwargs): from warnings import warn diff --git a/qcelemental/models/results.py b/qcelemental/models/results.py index 095ff684..13ce9252 100644 --- a/qcelemental/models/results.py +++ b/qcelemental/models/results.py @@ -12,7 +12,7 @@ from .types import Array -class ResultProperties(ProtoModel): +class AtomicResultProperties(ProtoModel): """ Named properties of quantum chemistry computations following the MolSSI QCSchema. """ @@ -258,7 +258,7 @@ class WavefunctionProtocolEnum(str, Enum): none = "none" -class ResultProtocols(ProtoModel): +class AtomicResultProtocols(ProtoModel): """ Protocols regarding the manipulation of a Result output data. """ @@ -286,7 +286,9 @@ class AtomicInput(ProtoModel): driver: DriverEnum = Field(..., description=str(DriverEnum.__doc__)) model: Model = Field(..., description=str(Model.__base_doc__)) keywords: Dict[str, Any] = Field({}, description="The program specific keywords to be used.") - protocols: ResultProtocols = Field(ResultProtocols(), description=str(ResultProtocols.__base_doc__)) + protocols: AtomicResultProtocols = Field( + AtomicResultProtocols(), description=str(AtomicResultProtocols.__base_doc__) + ) extras: Dict[str, Any] = Field({}, description="Extra fields that are not part of the schema.") @@ -303,7 +305,7 @@ def __repr_args__(self) -> "ReprArgs": class AtomicResult(AtomicInput): schema_name: constr(strip_whitespace=True, regex=qcschema_output_default) = qcschema_output_default # type: ignore - properties: ResultProperties = Field(..., description=str(ResultProperties.__base_doc__)) + properties: AtomicResultProperties = Field(..., description=str(AtomicResultProperties.__base_doc__)) wavefunction: Optional[WavefunctionProperties] = Field(None, description=str(WavefunctionProperties.__base_doc__)) return_result: Union[float, Array[float], Dict[str, Any]] = Field( @@ -425,6 +427,22 @@ def _stdout_protocol(cls, value, values): raise ValueError(f"Protocol `stdout:{outp}` is not understood") +def ResultProtocols(*args, **kwargs): + from warnings import warn + + warn("ResultProtocols has been renamed to AtomicResultProtocols and will be removed in v0.13.0", DeprecationWarning) + return AtomicResultProtocols(*args, **kwargs) + + +def ResultProperties(*args, **kwargs): + from warnings import warn + + warn( + "ResultProperties has been renamed to AtomicResultProperties and will be removed in v0.13.0", DeprecationWarning + ) + return AtomicResultProperties(*args, **kwargs) + + def ResultInput(*args, **kwargs): from warnings import warn diff --git a/qcelemental/molutil/test_molutil.py b/qcelemental/molutil/test_molutil.py index 4a559225..7b3871de 100644 --- a/qcelemental/molutil/test_molutil.py +++ b/qcelemental/molutil/test_molutil.py @@ -2,9 +2,9 @@ import pprint import numpy as np +import pydantic import pytest -import pydantic import qcelemental as qcel from qcelemental.testing import compare, compare_molrecs, compare_recursive, compare_values diff --git a/qcelemental/testing.py b/qcelemental/testing.py index 9fbf1d71..0280f6b3 100644 --- a/qcelemental/testing.py +++ b/qcelemental/testing.py @@ -5,7 +5,6 @@ from typing import Callable, Dict, List, Union import numpy as np - from pydantic import BaseModel pp = pprint.PrettyPrinter(width=120) diff --git a/qcelemental/tests/test_datum.py b/qcelemental/tests/test_datum.py index c0a42ff0..defb72a3 100644 --- a/qcelemental/tests/test_datum.py +++ b/qcelemental/tests/test_datum.py @@ -1,9 +1,9 @@ from decimal import Decimal import numpy as np +import pydantic import pytest -import pydantic import qcelemental as qcel from qcelemental.testing import compare_recursive, compare_values diff --git a/qcelemental/tests/test_model_general.py b/qcelemental/tests/test_model_general.py index 3d40c7e1..e860e5cf 100644 --- a/qcelemental/tests/test_model_general.py +++ b/qcelemental/tests/test_model_general.py @@ -1,6 +1,9 @@ import pytest from qcelemental.models import ( + AtomicInput, + AtomicResult, + AtomicResultProperties, ComputeError, FailedOperation, Molecule, @@ -8,15 +11,12 @@ OptimizationInput, ProtoModel, Provenance, - Result, - ResultInput, - ResultProperties, ) def test_result_properties_default_skip(): - obj = ResultProperties(scf_one_electron_energy="-5.0") + obj = AtomicResultProperties(scf_one_electron_energy="-5.0") assert pytest.approx(obj.scf_one_electron_energy) == -5.0 @@ -24,7 +24,7 @@ def test_result_properties_default_skip(): def test_result_properties_default_repr(): - obj = ResultProperties(scf_one_electron_energy="-5.0") + obj = AtomicResultProperties(scf_one_electron_energy="-5.0") assert "none" not in str(obj).lower() assert "scf_one_electron_energy" in str(obj) assert len(str(obj)) < 100 @@ -56,7 +56,7 @@ def test_repr_failed_op(): def test_repr_result(): - result = ResultInput( + result = AtomicInput( **{"driver": "gradient", "model": {"method": "UFF"}, "molecule": {"symbols": ["He"], "geometry": [0, 0, 0]}} ) assert "molecule_hash" in str(result) diff --git a/qcelemental/tests/test_model_results.py b/qcelemental/tests/test_model_results.py index e53ca536..55926d9c 100644 --- a/qcelemental/tests/test_model_results.py +++ b/qcelemental/tests/test_model_results.py @@ -214,25 +214,25 @@ def test_basis_map_raises(): def test_result_build(result_data_fixture): - ret = qcel.models.Result(**result_data_fixture) + ret = qcel.models.AtomicResult(**result_data_fixture) assert ret.wavefunction is None def test_result_build_wavefunction_delete(wavefunction_data_fixture): del wavefunction_data_fixture["protocols"] - ret = qcel.models.Result(**wavefunction_data_fixture) + ret = qcel.models.AtomicResult(**wavefunction_data_fixture) assert ret.wavefunction is None def test_wavefunction_build(wavefunction_data_fixture): - assert qcel.models.Result(**wavefunction_data_fixture) + assert qcel.models.AtomicResult(**wavefunction_data_fixture) def test_wavefunction_matrix_size_error(wavefunction_data_fixture): wavefunction_data_fixture["wavefunction"]["scf_orbitals_a"] = np.random.rand(2, 2) with pytest.raises(ValueError) as e: - qcel.models.Result(**wavefunction_data_fixture) + qcel.models.AtomicResult(**wavefunction_data_fixture) assert "castable to shape" in str(e.value) @@ -241,7 +241,7 @@ def test_wavefunction_return_result_pointer(wavefunction_data_fixture): del wavefunction_data_fixture["wavefunction"]["scf_orbitals_a"] with pytest.raises(ValueError) as e: - qcel.models.Result(**wavefunction_data_fixture) + qcel.models.AtomicResult(**wavefunction_data_fixture) assert "does not exist" in str(e.value) @@ -288,7 +288,7 @@ def test_wavefunction_protocols(protocol, restricted, provided, expected, wavefu else: wfn_data[scf_name] = np.random.rand(bas.nbf, bas.nbf) - wfn = qcel.models.Result(**wavefunction_data_fixture) + wfn = qcel.models.AtomicResult(**wavefunction_data_fixture) if len(expected) == 0: assert wfn.wavefunction is None @@ -305,7 +305,7 @@ def test_optimization_trajectory_protocol(keep, indices, optimization_data_fixtu if keep is not None: optimization_data_fixture["protocols"] = {"trajectory": keep} - opt = qcel.models.Optimization(**optimization_data_fixture) + opt = qcel.models.OptimizationResult(**optimization_data_fixture) assert len(opt.trajectory) == len(indices) for result, index in zip(opt.trajectory, indices): @@ -314,12 +314,12 @@ def test_optimization_trajectory_protocol(keep, indices, optimization_data_fixtu def test_result_build_stdout_delete(result_data_fixture): result_data_fixture["protocols"] = {"stdout": False} - ret = qcel.models.Result(**result_data_fixture) + ret = qcel.models.AtomicResult(**result_data_fixture) assert ret.stdout is None def test_result_build_stdout(result_data_fixture): - ret = qcel.models.Result(**result_data_fixture) + ret = qcel.models.AtomicResult(**result_data_fixture) assert ret.stdout == "I ran." @@ -342,3 +342,18 @@ def test_failed_operation(result_data_fixture): failed_json = failed.json() assert isinstance(failed_json, str) assert "its all good" in failed_json + + +def test_result_model_deprecations(result_data_fixture, optimization_data_fixture): + + with pytest.warns(DeprecationWarning): + qcel.models.ResultProperties(scf_one_electron_energy="-5.0") + + with pytest.warns(DeprecationWarning): + qcel.models.ResultInput(**{k: result_data_fixture[k] for k in ["molecule", "model", "driver"]}) + + with pytest.warns(DeprecationWarning): + qcel.models.Result(**result_data_fixture) + + with pytest.warns(DeprecationWarning): + qcel.models.Optimization(**optimization_data_fixture) diff --git a/qcelemental/tests/test_utils.py b/qcelemental/tests/test_utils.py index 27bd7ed3..876c664b 100644 --- a/qcelemental/tests/test_utils.py +++ b/qcelemental/tests/test_utils.py @@ -2,9 +2,9 @@ import numpy as np import pytest +from pydantic import BaseModel, Field import qcelemental as qcel -from pydantic import BaseModel, Field from qcelemental.testing import compare_recursive, compare_values from .addons import serialize_extensions diff --git a/qcelemental/util/serialization.py b/qcelemental/util/serialization.py index fec28dfd..d01918b9 100644 --- a/qcelemental/util/serialization.py +++ b/qcelemental/util/serialization.py @@ -2,7 +2,6 @@ from typing import Any, Union import numpy as np - from pydantic.json import pydantic_encoder from .importing import which_import diff --git a/setup.cfg b/setup.cfg index cbaea1e5..eb4b20be 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,7 +11,6 @@ omit = line_length=120 skip_glob = */data/nist* -skip=__init__.py include_trailing_comma=True force_grid_wrap=0 use_parentheses=True