Fix divide-by-zero in aromaticity index calculation#26
Fix divide-by-zero in aromaticity index calculation#26robertyoung3 wants to merge 2 commits intoEMSL-Computing:masterfrom
Conversation
ed6e03e to
615108a
Compare
kheal
left a comment
There was a problem hiding this comment.
Good find. According to the literature, if either the ai_n <= 0 OR the ai_d <= 0, then ai (or ai_mod) should be 0. Can you adjust to encapsulate these scenarios more generally? That will fix the the divide-by-zero bug as well.
Per Koch and Dittmar (2006), if either the numerator or denominator is non-positive, the aromaticity index should be 0. This is more general than only guarding against ai_d == 0 (divide-by-zero) and correctly handles all cases where AI is physically meaningless. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for the guidance! Updated to check both The Applied identically to both |
Summary
_calc_ai()and_calc_ai_mod()inMolecularFormulaCalcdivideai_n / ai_dwithout guarding againstai_d == 0ZeroDivisionErrorfor molecular formulas whereC - 0.5*O - N - S(orC - O - N - Sfor modified AI) equals zero[0, 1]Before
After
Applied to both
_calc_ai()(line 563) and_calc_ai_mod()(line 604).References
Test plan