Skip to content

Ion: handle dissolved gas formulas - #3275

Merged
janosh merged 2 commits into
materialsproject:masterfrom
rkingsbury:ion_rform
Aug 28, 2023
Merged

Ion: handle dissolved gas formulas#3275
janosh merged 2 commits into
materialsproject:masterfrom
rkingsbury:ion_rform

Conversation

@rkingsbury

Copy link
Copy Markdown
Contributor

Summary

Ion.reduced_formula does not correctly handle dissolved gas molecules, such as O2, for example:

>>> Ion.from_formula('O2').get_reduced_formula_and_factor()
('O', 2)
>>> Ion.from_formula('O2').formula
'O2 (aq)'
>>> Ion.from_formula('O2').reduced_formula
'O(aq)'

This PR modifies Ion.get_reduced_formula_and_factor to correctly report dissolved formulas of dissolved gases H2, N2, O2, F2, Cl2, and O3. It also updates the docstrings of formula and reduced_formula.

Checklist

  • Google format doc strings added. Check with ruff.
  • Type annotations included. Check with mypy.
  • Tests added for new features/fixes.

@rkingsbury

Copy link
Copy Markdown
Contributor Author

@materialsproject/pymatgen-maintainers there are a handful of test failures here that seem unrelated to the changes in this PR. I believe I am up to date with the latest master branch; please advise if further changes are needed. Thanks!

@janosh janosh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @rkingsbury! 👍

@janosh
janosh merged commit d027466 into materialsproject:master Aug 28, 2023
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

Successfully merging this pull request may close these issues.

2 participants