Skip to content
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

Open
jcumby opened this issue Jun 21, 2022 · 1 comment
Open

Balancing reactions with non-integer stoichiometry #211

jcumby opened this issue Jun 21, 2022 · 1 comment

Comments

@jcumby
Copy link

jcumby commented Jun 21, 2022

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!

@jeremyagray
Copy link
Collaborator

jeremyagray commented Jun 21, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants