From 049ab9b722a1a83396bd47208220174e49d621be Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Mon, 27 Nov 2023 11:47:31 -0800 Subject: [PATCH] revert module-scoped SymmOp import causing circular import --- pymatgen/symmetry/groups.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pymatgen/symmetry/groups.py b/pymatgen/symmetry/groups.py index 2cc2de961c4..a3855792a78 100644 --- a/pymatgen/symmetry/groups.py +++ b/pymatgen/symmetry/groups.py @@ -18,7 +18,6 @@ from monty.design_patterns import cached_class from monty.serialization import loadfn -from pymatgen.core.operations import SymmOp from pymatgen.util.string import Stringify if TYPE_CHECKING: @@ -26,6 +25,7 @@ # don't import at runtime to avoid circular import from pymatgen.core.lattice import Lattice + from pymatgen.core.operations import SymmOp # noqa: TCH004 SYMM_DATA = loadfn(os.path.join(os.path.dirname(__file__), "symm_data.json")) @@ -115,6 +115,8 @@ def __init__(self, int_symbol: str) -> None: Args: int_symbol (str): International or Hermann-Mauguin Symbol. """ + from pymatgen.core.operations import SymmOp + self.symbol = int_symbol self.generators = [ SYMM_DATA["generator_matrices"][enc] for enc in SYMM_DATA["point_group_encoding"][int_symbol] @@ -205,6 +207,8 @@ def __init__(self, int_symbol: str) -> None: classmethod. Alternative origin choices can be indicated by a translation vector, e.g., 'Fm-3m(a-1/4,b-1/4,c-1/4)'. """ + from pymatgen.core.operations import SymmOp + int_symbol = re.sub(r" ", "", int_symbol) if int_symbol in SpaceGroup.abbrev_sg_mapping: int_symbol = SpaceGroup.abbrev_sg_mapping[int_symbol] @@ -315,6 +319,8 @@ def symmetry_ops(self) -> set[SymmOp]: """Full set of symmetry operations as matrices. Lazily initialized as generation sometimes takes a bit of time. """ + from pymatgen.core.operations import SymmOp + if self._symmetry_ops is None: self._symmetry_ops = {SymmOp(m) for m in self._generate_full_symmetry_ops()} return self._symmetry_ops @@ -351,6 +357,8 @@ def get_orbit_and_generators(self, p: ArrayLike, tol: float = 1e-5) -> tuple[lis Returns: tuple[list[np.ndarray], list[SymmOp]]: Orbit and generators for point. """ + from pymatgen.core.operations import SymmOp + orbit: list[np.ndarray] = [np.array(p, dtype=float)] identity = SymmOp.from_rotation_and_translation(np.eye(3), np.zeros(3)) generators: list[np.ndarray] = [identity]