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

Breaking: return sum of Species with matching Element in Composition.__getitem__ #3427

Merged
merged 6 commits into from
Oct 26, 2023

Conversation

janosh
Copy link
Member

@janosh janosh commented Oct 26, 2023

Closes #3425.

Follow up to #3184 since that turns out to only have been a partial fix for not applying anion corrections to ComputedEntries with oxidation states.

The bug comes from Composition indexing behaving differently for Elements/str vs. Species. Currently:

comp = Composition({"Li+": 2, "Mn3+": 2, "O2-": 4})
comp["Li"] == 0

This PR changes comp["Li"] to return 2 instead, i.e. return all species with matching symbol, regardless of oxidation state. Currently comp["O"] returns 0 and so no oxide correction is applied.

This is breaking. E.g. currently

comp = Composition({"Mg": 1, "Mg2+": -1}, allow_negative=True)
comp["Mg"] == 1

which will change to return 0.

@janosh janosh added fix Bug fix PRs breaking Breaking change core Pymatgen core mixing-schemes About mixing energies from different DFT functionals labels Oct 26, 2023
@janosh janosh enabled auto-merge (squash) October 26, 2023 19:26
@janosh janosh merged commit bd13ea4 into master Oct 26, 2023
21 checks passed
@janosh janosh deleted the fix-gh-3425 branch October 26, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking change core Pymatgen core fix Bug fix PRs mixing-schemes About mixing energies from different DFT functionals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MP2020Compatibility not applying correct anion correction
1 participant