From ae413bb180d5646ab5cd885351e13d26d61de100 Mon Sep 17 00:00:00 2001 From: Tyler Mathis <35553152+tsmathis@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:16:40 -0700 Subject: [PATCH] move imports into robocrys func robocrys is an extra import in emmet-core --- emmet-core/emmet/core/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/emmet-core/emmet/core/utils.py b/emmet-core/emmet/core/utils.py index e92f8024d4..21a9648149 100644 --- a/emmet-core/emmet/core/utils.py +++ b/emmet-core/emmet/core/utils.py @@ -21,8 +21,6 @@ DeformStructureTransformation, ) from pymatgen.util.graph_hashing import weisfeiler_lehman_graph_hash -from robocrys import StructureCondenser, StructureDescriber -from robocrys.condense.mineral import MineralMatcher from emmet.core.mpid import MPculeID from emmet.core.settings import EmmetSettings @@ -109,8 +107,15 @@ def undeform_structure(structure: Structure, transformations: Dict) -> Structure def generate_robocrys_condensed_struct_and_description( - structure: Structure, mineral_matcher: MineralMatcher | None = None + structure: Structure, mineral_matcher=None ) -> tuple[dict[Any], str]: + try: + from robocrys import StructureCondenser, StructureDescriber + except ImportError: + raise ImportError( + "robocrys needs to be installed to generate Robocrystallographer descriptions" + ) + condenser = StructureCondenser(mineral_matcher=mineral_matcher) describer = StructureDescriber( describe_symmetry_labels=False, fmt="unicode", return_parts=False