You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you have a formula with only 1 atom of the element (let's say H2O or HPO4), the function "parse_formula(formula)" would crash in line 123: composition[_make_isotope_string(elem, int(isotope) if isotope else 0)] += int(number):
ValueError: invalid literal for int() with base 10: ''
Changing the line to: composition[_make_isotope_string(elem, int(isotope) if isotope else 0)] += int(number) if number else 1 fixes that error.
Thank you for taking the time to review the problem. Did you run this with the C-extensions enabled?
The C formula parser does not handle implicit single atoms either, but is a hand-written state machine based parser for efficiency, where this behavior would be more difficult to achieve. I left this behavior off of the Python implementation to maintain parity between the two versions.
When you have a formula with only 1 atom of the element (let's say H2O or HPO4), the function "parse_formula(formula)" would crash in line 123:
composition[_make_isotope_string(elem, int(isotope) if isotope else 0)] += int(number)
:Changing the line to:
composition[_make_isotope_string(elem, int(isotope) if isotope else 0)] += int(number) if number else 1
fixes that error.I have requested a pull request to fix the bug #1
The text was updated successfully, but these errors were encountered: