From 4eca0c1eed12e4b6fcd5c5d6555f40b993fbd2a7 Mon Sep 17 00:00:00 2001 From: Shyam D Date: Thu, 1 Oct 2020 18:42:48 -0700 Subject: [PATCH] fix imports --- emmet-core/emmet/core/structure.py | 2 +- emmet-core/emmet/core/utils.py | 2 +- emmet-core/emmet/core/vasp/calc_types.py | 2 +- emmet-core/emmet/core/xas.py | 2 +- emmet-core/emmet/stubs/__init__.py | 2 +- emmet-core/emmet/stubs/misc.py | 2 +- emmet-core/emmet/stubs/structure.py | 2 +- emmet-core/emmet/stubs/utils.py | 5 +++-- emmet-core/emmet/stubs/xas.py | 2 +- 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/emmet-core/emmet/core/structure.py b/emmet-core/emmet/core/structure.py index 89688c7476..f4749c71b3 100644 --- a/emmet-core/emmet/core/structure.py +++ b/emmet-core/emmet/core/structure.py @@ -2,7 +2,7 @@ from typing import List, Optional, Type, TypeVar, overload from pydantic import BaseModel, Field -from pymatgen import Element +from pymatgen.core.periodic_table import Element from emmet.core.symmetry import SymmetryData from emmet.stubs import Composition, Structure diff --git a/emmet-core/emmet/core/utils.py b/emmet-core/emmet/core/utils.py index 7e5aba44be..34010cefc3 100644 --- a/emmet-core/emmet/core/utils.py +++ b/emmet-core/emmet/core/utils.py @@ -9,7 +9,7 @@ from monty.json import MSONable from monty.serialization import loadfn from pydantic import BaseModel -from pymatgen import Structure +from pymatgen.core.structure import Structure from pymatgen.analysis.structure_matcher import ElementComparator, StructureMatcher from typing_extensions import Literal diff --git a/emmet-core/emmet/core/vasp/calc_types.py b/emmet-core/emmet/core/vasp/calc_types.py index 6ef38d2d03..322f2d4366 100644 --- a/emmet-core/emmet/core/vasp/calc_types.py +++ b/emmet-core/emmet/core/vasp/calc_types.py @@ -10,7 +10,7 @@ from monty.json import MSONable from monty.serialization import loadfn from pydantic import BaseModel -from pymatgen import Structure +from pymatgen.core.structure import Structure from pymatgen.analysis.structure_matcher import ElementComparator, StructureMatcher from typing_extensions import Literal diff --git a/emmet-core/emmet/core/xas.py b/emmet-core/emmet/core/xas.py index cda7f82bc6..984851ad26 100644 --- a/emmet-core/emmet/core/xas.py +++ b/emmet-core/emmet/core/xas.py @@ -3,7 +3,7 @@ from typing import List, Optional from pydantic import BaseModel, Field, root_validator -from pymatgen import Element +from pymatgen.core.periodic_table import Element from emmet.core.spectrum import SpectrumDoc from emmet.stubs import XAS, Structure diff --git a/emmet-core/emmet/stubs/__init__.py b/emmet-core/emmet/stubs/__init__.py index c2c7e076f4..0cf5d146a2 100644 --- a/emmet-core/emmet/stubs/__init__.py +++ b/emmet-core/emmet/stubs/__init__.py @@ -4,7 +4,7 @@ """ -from pymatgen import Composition, Structure +from pymatgen.core.structure import Composition, Structure from pymatgen.analysis.xas.spectrum import XAS from pymatgen.entries.computed_entries import ComputedEntry diff --git a/emmet-core/emmet/stubs/misc.py b/emmet-core/emmet/stubs/misc.py index 2354b1459c..2eae31bde9 100644 --- a/emmet-core/emmet/stubs/misc.py +++ b/emmet-core/emmet/stubs/misc.py @@ -1,7 +1,7 @@ from typing import Dict, List, Optional, Tuple, Union from pydantic import BaseModel, Field -from pymatgen import Element +from pymatgen.core.periodic_table import Element class Composition(BaseModel): diff --git a/emmet-core/emmet/stubs/structure.py b/emmet-core/emmet/stubs/structure.py index ed01df6616..ca74a4c9a4 100644 --- a/emmet-core/emmet/stubs/structure.py +++ b/emmet-core/emmet/stubs/structure.py @@ -1,7 +1,7 @@ from typing import Dict, List, Optional, Tuple, Union from pydantic import BaseModel, Field -from pymatgen import Element +from pymatgen.core.periodic_table import Element from emmet.stubs import Vector3D diff --git a/emmet-core/emmet/stubs/utils.py b/emmet-core/emmet/stubs/utils.py index 601a9630d4..82787b3a36 100644 --- a/emmet-core/emmet/stubs/utils.py +++ b/emmet-core/emmet/stubs/utils.py @@ -152,6 +152,7 @@ def MSONable_to_pydantic(monty_cls: type, pydantic_model=None): for field_name, field_type in _type_hints } - model = create_model(monty_cls.__name__, **monty_props, **props) - model.__doc__ = monty_cls.__doc__ + model = create_model(monty_cls.__name__,field_definitions={**monty_props, **props}) + if hasattr(monty_cls,"__doc__"): + setattr(model,"__doc__",monty_cls.__doc__) return model diff --git a/emmet-core/emmet/stubs/xas.py b/emmet-core/emmet/stubs/xas.py index f10789dae1..4dfa38d0ec 100644 --- a/emmet-core/emmet/stubs/xas.py +++ b/emmet-core/emmet/stubs/xas.py @@ -2,7 +2,7 @@ from typing import Dict, List, Optional, Tuple, Union from pydantic import BaseModel, Field -from pymatgen import Element +from pymatgen.core.periodic_table import Element from emmet.stubs import Structure