-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Balancing reactions with non-integer stoichiometry #211
Comments
This is a known issue (
#207 (comment)) with
the newly updated parser but there is a partial solution linked in the
above comment. I blame unicode because there are symbols for everything
else. The only resolution at this time is to decide on a “good enough”
symbol to use in place of the subscript and superscript decimal point, but
there are still localization issues because not everyone uses the same
decimal point. I haven’t had time to compare the alternatives and the ones
I’ve found were not great. Plus, there is the not small issue of
documenting and educating users to use some special dot as a
sub/superscript decimal.
The ASCII, HTML, and LaTeX parsers should all handle this and the issue is
not present in the last release.
On Tue, Jun 21, 2022 at 10:51 James Cumby ***@***.***> wrote:
Issue
Balancing a reaction using non-integer stoichiometry results in a KeyError:
'.'
Example:
chempy.balance_stoichiometry(['NbO2F','FeF3'], ['Nb1.5Fe0.5O3F3'])
results in:
c:\users\jcumby\local documents\custom_python_libs\chempy\chempy\chempy\util\parsing.py in <genexpr>(.0)
648 infixes = _unicode_infix_mapping
649 return _formula_to_format(--> 650 lambda x: "".join(_unicode_sub[str(_)] for _ in x),
651 lambda x: "".join(_unicode_sup[str(_)] for _ in x),
652 formula,
KeyError: '.'
Cause
The dict _unicode_sub defined in parsing.py has unicode subscript
definitions for all numbers, but not for a dot, leading to the KeyError.
Solution
Unicode does not (I think?) have a subscript dot, so I can't find an
obvious solution. Currently I have added a simple '.' to the _unicode_sub
dict to solve the KeyError, but this does not give a correct Unicode
representation. Hopefully someone more familiar with unicode has a better
suggestion!
—
Reply to this email directly, view it on GitHub
<#211>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOQCHS5PQFRZWX3WG67AHOTVQHQH3ANCNFSM5ZM23Z6A>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Jeremy A Gray
Gray Farms
www.grayfarms.org
205.544.4573
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue
Balancing a reaction using non-integer stoichiometry results in a
KeyError: '.'
Example:
results in:
Cause
The dict
_unicode_sub
defined inparsing.py
has unicode subscript definitions for all numbers, but not for a dot, leading to theKeyError
.Solution
Unicode does not (I think?) have a subscript dot, so I can't find an obvious solution. Currently I have added a simple '.' to the
_unicode_sub
dict to solve the KeyError, but this does not give a correct Unicode representation. Hopefully someone more familiar with unicode has a better suggestion!The text was updated successfully, but these errors were encountered: