Skip to content

Commit

Permalink
Tentative fix for gh-223
Browse files Browse the repository at this point in the history
  • Loading branch information
bjodah committed Jul 24, 2023
1 parent 1ef1bf6 commit e32e4e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions chempy/tests/test_chemistry.py
Expand Up @@ -58,6 +58,10 @@ def test_Substance__from_formula():
assert H2O.unicode_name == u"H₂O"
assert H2O.html_name == u"H<sub>2</sub>O"

# see https://github.com/bjodah/chempy/issues/223
zinc_nitrate = Substance.from_formula("Zn(NO3)2.6H2O")
assert zinc_nitrate.composition == {30: 1, 7: 2, 8: 3*2+6, 1: 12}


@requires(parsing_library)
def test_Species():
Expand Down
5 changes: 4 additions & 1 deletion chempy/util/parsing.py
Expand Up @@ -600,14 +600,17 @@ def formula_to_latex(formula, prefixes=None, infixes=None, **kwargs):
)


_unicode_sub = {}
_unicode_sub = {
'.': "\u0323",
}

for k, v in enumerate("₀₁₂₃₄₅₆₇₈₉"):
_unicode_sub[str(k)] = v

_unicode_sup = {
"+": "⁺",
"-": "⁻",
'.': "\u02d9"
}

for k, v in enumerate("⁰¹²³⁴⁵⁶⁷⁸⁹"):
Expand Down

0 comments on commit e32e4e5

Please sign in to comment.