Skip to content

Commit

Permalink
additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rkingsbury committed Jul 20, 2024
1 parent 1398996 commit 67e27e3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/pyEQL/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,30 @@ def standardize_formula(formula: str):
# haloacetic acids of F, Cl, Br, I
elif sform == "C2Cl3O2[-1]":
sform = "CCl3COO[-1]"
elif sform == "C2F3O2[-1]":
elif sform == "C2O2F3[-1]":
sform = "CF3COO[-1]"
elif sform == "C2I3O2[-1]":
sform = "CI3COO[-1]"
elif sform == "C2Br3O2[-1]":
sform = "CBr3COO[-1]"

# F+Cl
# Cl+F
elif sform == "C2Cl2O2F[-1]":
sform = "CFCl2COO[-1]"
elif sform == "C2Cl(OF)2[-1]":
sform = "CF2ClCOO[-1]"

Check warning on line 123 in src/pyEQL/utils.py

View check run for this annotation

Codecov / codecov/patch

src/pyEQL/utils.py#L123

Added line #L123 was not covered by tests

# Cl+Br
elif sform == "C2Cl2O2Br[-1]":
sform = "CFCl2COO[-1]"
elif sform == "C2Br(ClO)2[-1]":
sform = "CCl2BrCOO[-1]"
elif sform == "C2Cl(OBr)2[-1]":
sform = "CF2ClCOO[-1]"
sform = "CClBr2ClCOO[-1]"

Check warning on line 129 in src/pyEQL/utils.py

View check run for this annotation

Codecov / codecov/patch

src/pyEQL/utils.py#L129

Added line #L129 was not covered by tests

# Cl+I
elif sform == "C2I(ClO)2[-1]":
sform = "CCl2ICOO[-1]"
elif sform == "C2Cl(OI)2[-1]":
sform = "CClI2COO[-1]"

Check warning on line 135 in src/pyEQL/utils.py

View check run for this annotation

Codecov / codecov/patch

src/pyEQL/utils.py#L135

Added line #L135 was not covered by tests

# TODO - consider adding recognition of special formulas like MeOH for methanol or Cit for citrate
return sform
Expand Down
8 changes: 8 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def test_standardize_formula():
# superscripts, subscripts, and permuted sign/charge number
assert standardize_formula("PO₄³⁻") == "PO4[-3]"
assert standardize_formula("Co²⁺") == "Co[+2]"
# haloacetic acids
assert standardize_formula("CCl3COO-") == "CCl3COO[-1]"
assert standardize_formula("CF3COO-") == "CF3COO[-1]"
assert standardize_formula("CI3COO-") == "CI3COO[-1]"
assert standardize_formula("CBr3COO-") == "CBr3COO[-1]"
assert standardize_formula("CCl2ICOO-") == "CCl2ICOO[-1]"
assert standardize_formula("CCl2BrCOO-") == "CCl2BrCOO[-1]"
assert standardize_formula("CCl2FCOO-") == "CFCl2COO[-1]"


def test_formula_dict():
Expand Down

0 comments on commit 67e27e3

Please sign in to comment.