Skip to content

Commit 20f2f13

Browse files
committed
f engine import
1 parent a3c1cd9 commit 20f2f13

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

arc/mapping/engine.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
from arc.family import ReactionFamily
1818
from arc.molecule import Molecule
1919
from arc.molecule.resonance import generate_resonance_structures_safely
20-
from arc.species import ARCSpecies
21-
from arc.species.conformers import determine_chirality
2220
from arc.species.converter import compare_confs, sort_xyz_using_indices, xyz_from_data
2321
from arc.species.vectors import calculate_dihedral_angle, get_delta_angle
2422

23+
# ``ARCSpecies`` and ``determine_chirality`` are imported locally in their
24+
# call-sites to break a circular import via arc.species → arc.plotter → here.
2525
if TYPE_CHECKING:
2626
from arc.molecule.molecule import Atom
2727
from arc.reaction import ARCReaction
28+
from arc.species import ARCSpecies
2829

2930
RESERVED_FINGERPRINT_KEYS = ['self', 'chirality', 'label']
3031

@@ -137,7 +138,7 @@ def map_two_species(spc_1: ARCSpecies | Molecule,
137138
return atom_map
138139

139140

140-
def get_arc_species(spc: ARCSpecies | Molecule) -> ARCSpecies:
141+
def get_arc_species(spc: "ARCSpecies | Molecule") -> "ARCSpecies":
141142
"""
142143
Convert an object to an ARCSpecies object.
143144
@@ -147,6 +148,7 @@ def get_arc_species(spc: ARCSpecies | Molecule) -> ARCSpecies:
147148
Returns:
148149
ARCSpecies: The corresponding ARCSpecies object.
149150
"""
151+
from arc.species import ARCSpecies
150152
if isinstance(spc, ARCSpecies):
151153
return spc
152154
if isinstance(spc, Molecule):
@@ -250,6 +252,7 @@ def fingerprint(spc: ARCSpecies,
250252
dict[int, dict[str, list[int]]]: Keys are indices of heavy atoms, values are dicts. keys are element symbols,
251253
values are indices of adjacent atoms corresponding to this element.
252254
"""
255+
from arc.species.conformers import determine_chirality
253256
fingerprint_dict = dict()
254257
chirality_dict = determine_chirality(conformers=[{'xyz': spc.get_xyz()}],
255258
label=spc.label,
@@ -1135,7 +1138,7 @@ def make_bond_changes(rxn: ARCReaction, r_cuts: list[ARCSpecies], r_label_dict:
11351138
r_cut.mol = r_cut_mol_copy
11361139

11371140

1138-
def update_xyz(species: list[ARCSpecies]) -> list[ARCSpecies]:
1141+
def update_xyz(species: "list[ARCSpecies]") -> "list[ARCSpecies]":
11391142
"""
11401143
A helper function, updates the xyz values of each species after cutting. This is important, since the
11411144
scission sometimes scrambles the Molecule object, and updating the xyz makes up for that.
@@ -1146,6 +1149,7 @@ def update_xyz(species: list[ARCSpecies]) -> list[ARCSpecies]:
11461149
Returns:
11471150
list[ARCSpecies]: A newly generated copies of the ARCSpecies, with updated xyz.
11481151
"""
1152+
from arc.species import ARCSpecies
11491153
new = list()
11501154
for spc in species:
11511155
new_spc = ARCSpecies(label="copy", mol=spc.mol.copy(deep=True))
@@ -1485,6 +1489,7 @@ def find_all_breaking_bonds(rxn: "ARCReaction",
14851489
broken bond (1-indexed), representing the atom indices to be cut.
14861490
Returns ``None`` if ``rxn.family`` is not set or ``rxn.product_dicts`` is empty.
14871491
"""
1492+
from arc.species import ARCSpecies
14881493
if rxn.family is None:
14891494
return None
14901495
family = ReactionFamily(label=rxn.family)

0 commit comments

Comments
 (0)