Skip to content

Commit

Permalink
precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
esoteric-ephemera authored and tsmathis committed Sep 12, 2024
1 parent e4cc326 commit 5c26dd0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
9 changes: 5 additions & 4 deletions emmet-core/emmet/core/robocrys.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ def from_structure(
mineral_matcher: MineralMatcher | None = None,
**kwargs
):
condensed_structure, description = (
generate_robocrys_condensed_struct_and_description(
structure=structure, mineral_matcher=mineral_matcher
)
(
condensed_structure,
description,
) = generate_robocrys_condensed_struct_and_description(
structure=structure, mineral_matcher=mineral_matcher
)

return super().from_structure(
Expand Down
15 changes: 8 additions & 7 deletions emmet-core/emmet/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import copy
import datetime
from enum import Enum
Expand Down Expand Up @@ -110,8 +109,8 @@ def undeform_structure(structure: Structure, transformations: Dict) -> Structure

def generate_robocrys_condensed_struct_and_description(
structure: Structure,
mineral_matcher : Optional[MineralMatcher] = None,
symprecs : list[float] = [0.01, 0.1, 1.e-3]
mineral_matcher: Optional[MineralMatcher] = None,
symprecs: list[float] = [0.01, 0.1, 1.0e-3],
) -> tuple[dict[Any], str]:
"""
Get robocrystallographer description of a structure.
Expand All @@ -120,7 +119,7 @@ def generate_robocrys_condensed_struct_and_description(
------
structure : pymatgen .Structure
mineral_matcher : optional robocrys MineralMatcher object
Slightly reduces load time by storing mineral data
Slightly reduces load time by storing mineral data
in memory, rather than reloading for each structure.
symprecs : list[float]
A list of symprec values to try for symmetry identification.
Expand All @@ -137,18 +136,20 @@ def generate_robocrys_condensed_struct_and_description(
raise ImportError(
"robocrys needs to be installed to generate Robocrystallographer descriptions"
)

for isymprec, symprec in enumerate(symprecs):
# occasionally, symmetry detection fails - give a few chances to modify symprec
try:
condenser = StructureCondenser(mineral_matcher=mineral_matcher, symprec=symprec)
condenser = StructureCondenser(
mineral_matcher=mineral_matcher, symprec=symprec
)
condensed_structure = condenser.condense_structure(structure)
break
except ValueError as exc:
if isymprec == len(symprecs) - 1:
raise exc

for desc_fmt in ["unicode","html","raw"]:
for desc_fmt in ["unicode", "html", "raw"]:
try:
describer = StructureDescriber(
describe_symmetry_labels=False, fmt=desc_fmt, return_parts=False
Expand Down

0 comments on commit 5c26dd0

Please sign in to comment.