Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR contains some miscellaneous bugfixes and enhancements for the
Ion
class.formula
andreduced_formula
for diatomic molecules and Ions #2204 by overloadingget_reduced_formula_and_factor
to provide special formula handling for ions. Thereduced_formula
for hydroxide, hydrogen peroxide, acetate, acetic acid, and small alcohols are now more consistent with the way these species are usually written.utils.string.charge_string
method to make the representation of ion charges more consistent acrossformula
,reduced_formula
, etc.Ion
formulae more consistent. By default, charges are now always appended in brackets, with the sign preceding the magnitude, e.g.Na[+1]
orSO4[-2]
. This provides unambiguous differentiation between stoichiometric coefficients and charges, and will facilitate usingIon.reduced_formula
as database keys in, e.g., the Pourbaix ion data. For unchargedIon
, the formula is always followed by(aq)
.Zr(OH)4(aq)
becomesZrO2.2H2O(aq)
to_latex_string
andIon.from_formula
Additional dependencies introduced (if any)
None
Checklist
is to run the following in the correct sequence on your local machine. Start with running
black on your new code. This will automatically reformat
your code to PEP8 conventions and removes most issues. Then run
pycodestyle, followed by
flake8.
Run pydocstyle on your code.