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

Ion: handle dissolved gas formulas #3275

Merged
merged 2 commits into from Aug 28, 2023

Conversation

rkingsbury
Copy link
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
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!

Copy link
Member

@janosh janosh left a comment

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
26 of 30 checks passed
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.

None yet

2 participants