From 08c634398125d930b6500111b15cc97abeef090d Mon Sep 17 00:00:00 2001 From: Richard West Date: Fri, 4 Jun 2021 22:25:12 -0400 Subject: [PATCH] Using lazy string formatting in debug statements. Doing it this way, the string formatting is not evaluated if you aren't actually going to log the debug statements (usually the case, as we normally don't run in verbose mode). Should be marginally quicker. --- rmgpy/molecule/resonance.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rmgpy/molecule/resonance.py b/rmgpy/molecule/resonance.py index 1ecd4c6249..6d8c9ffed8 100644 --- a/rmgpy/molecule/resonance.py +++ b/rmgpy/molecule/resonance.py @@ -306,23 +306,23 @@ def _generate_resonance_structures(mol_list, method_list, keep_isomorphic=False, for mol in mol_list[1:]: if mol.get_net_charge() != input_charge: mol_list.remove(mol) - logging.debug('Resonance generation created a molecule {0} with a net charge of {1}\n' - 'which does not match the input mol charge of {2}' - 'Removing {0} from resonance structures'.format(mol.smiles,mol.get_net_charge(),input_charge)) + logging.debug('Resonance generation created a molecule %s with a net charge of %d ' + 'which does not match the input mol charge of %d.\n' + 'Removing it from resonance structures',mol.smiles,mol.get_net_charge(),input_charge) if mol.contains_surface_site(): for x in [atom for atom in mol.atoms if atom.is_surface_site()]: if x.radical_electrons != 0: mol_list.remove(mol) - logging.debug('Resonance generation created a molecule {0} with {1} radicals on {2}\n' - 'Removing {0} from resonance structures'.format(mol.smiles,x.radical_electrons,x.symbol)) + logging.debug('Resonance generation created a molecule %s with %d radicals on %s.\n' + 'Removing it from resonance structures',mol.smiles,x.radical_electrons,x.symbol) elif x.lone_pairs != 0: mol_list.remove(mol) - logging.debug('Resonance generation created a molecule {0} with {1} lone pairs on {2}\n' - 'Removing {0} from resonance structures'.format(mol.smiles,x.lone_pairs,x.symbol)) + logging.debug('Resonance generation created a molecule %s with %d lone pairs on %s.\n' + 'Removing it from resonance structures',mol.smiles,x.lone_pairs,x.symbol) elif x.charge != 0: mol_list.remove(mol) - logging.debug('Resonance generation created a molecule {0} with a charge of {1} on {2}\n' - 'Removing {0} from resonance structures'.format(mol.smiles,x.charge,x.symbol)) + logging.debug('Resonance generation created a molecule %s with a charge of %d on %s.\n' + 'Removing it from resonance structures',mol.smiles,x.charge,x.symbol) return mol_list