From ffb90b29cc5410c0009fda2cdd793b64f0aac44a Mon Sep 17 00:00:00 2001 From: Richard West Date: Fri, 2 Aug 2024 10:59:36 -0400 Subject: [PATCH 1/2] Minor: Fix a Cython declaration in a Reaction method. Although Atom is a subclass of Vertex, it adds an element attribute. This leads to more efficient Cython code (and quietens a warning in vscode). --- rmgpy/reaction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmgpy/reaction.py b/rmgpy/reaction.py index a8ae13f3d3a..477e29cc965 100644 --- a/rmgpy/reaction.py +++ b/rmgpy/reaction.py @@ -1447,7 +1447,7 @@ def is_balanced(self): from rmgpy.molecule.element import element_list from rmgpy.molecule.fragment import CuttingLabel, Fragment - cython.declare(reactant_elements=dict, product_elements=dict, molecule=Graph, atom=Vertex, element=Element, + cython.declare(reactant_elements=dict, product_elements=dict, molecule=Molecule, atom=Atom, element=Element, reactants_net_charge=cython.int, products_net_charge=cython.int) reactant_elements = {} From b1d63ef345b8970928b0d1ac224de3115bed1a92 Mon Sep 17 00:00:00 2001 From: Richard West Date: Thu, 9 Apr 2026 11:17:47 -0400 Subject: [PATCH 2/2] Fix species rename from thermo library for reaction-generated species MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7318b37 introduced a `rename` flag to `generate_thermo` to prevent user-labelled initial species from being silently renamed by a library match. However, it called `generate_thermo(spec)` (rename=False) inside `make_new_species`, caching `spec.thermo` before the rename-enabled call in `apply_thermo_to_species` could run — so the `if not spc.thermo` guard in `generate_thermo` always short-circuited the rename for reaction products, leaving them with SMILES labels (e.g. "O=O") instead of their library names (e.g. "O2(S)"). Fix: pass `rename=not bool(spec.label)` so that reaction-generated species (no label yet) are renamed from the library entry, while user-labelled initial species are left unchanged. Co-Authored-By: Claude Sonnet 4.6 --- rmgpy/rmg/model.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rmgpy/rmg/model.py b/rmgpy/rmg/model.py index f937ac88424..225c8f55399 100644 --- a/rmgpy/rmg/model.py +++ b/rmgpy/rmg/model.py @@ -365,10 +365,11 @@ def make_new_species(self, object, label="", reactive=True, check_existing=True, spec.molecular_weight = Quantity(spec.molecule[0].get_molecular_weight() * 1000.0, "amu") if generate_thermo: - self.generate_thermo(spec) + # Rename from thermo library label only if no user-provided label exists yet. + self.generate_thermo(spec, rename=not bool(spec.label)) # If the species still does not have a label, set initial label as the SMILES - # This may change later after getting thermo in self.generate_thermo() + # (applies when generate_thermo is False, or when no library match was found) if not spec.label: spec.label = spec.smiles