Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert pymatgen/symmetry/groups.py module-scoped SymmOp import causing circular import #3486

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading