Skip to content

Commit

Permalink
revert module-scoped SymmOp import causing circular import (#3486)
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh authored Nov 27, 2023
1 parent 68cf6b4 commit 3a58824
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pymatgen/symmetry/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
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:
from numpy.typing import ArrayLike

# 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"))
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 3a58824

Please sign in to comment.