-
Notifications
You must be signed in to change notification settings - Fork 871
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 True for Element in Composition
if Species.symbol
matches Element
#3184
Conversation
- Species in Composition - Element in Composition with Species - str in Composition with Element - int (atomic number) in Composition - float in Composition - DummySpecies in Composition
> assert len(processed_entry.energy_adjustments) == 1 E AssertionError: assert 2 == 1
expected wrong error msg
4ea72bf
to
8f77195
Compare
Composition.__contains__
Element in Composition
if Species.symbol
matches Element
Yikes, this is a pretty significant bug. So if I understand #3185 correctly, if one applies I agree this should definitely be fixed as you've shown. Tagging @awvio in case she has any thoughts about impact on the correction scheme. My recollection is that when we developed and fit the new corrections, we always used un-decorated structures, and then either populated |
@rkingsbury That's correct. This came up in the context of CHGNet which can infer oxidation states on structures from predicted magmoms. Applying the correction scheme to these structures did not include any oxide/sulfide corrections (search for
I think so too. @esoteric-ephemera kindly checked all MP ComputedStructureEntries and found none containing oxidation states. |
I believe @rkingsbury is correct, this should not have affected the corrections we fit since the entries should have had the oxidation states added during the fitting. |
Closes #3185.
Element in Composition
is currentlyFalse
if thatElement
appears inComposition
as aSpecies
with an oxidation state.This PR changes the
__contains__
method to returnTrue
forx in Composition
ifx
exactly matches aSpecies
(both element symbol and oxidation state) in the composition (same as before)x
is anElement
and aSpecies
with matching element symbol is present, regardless of oxidation state (returnedFalse
before).It does not change behavior for the reverse, i.e. if a
Species in Composition
is stillFalse
if only itsElement
without oxidation state is in theComposition
.This is strictly speaking a breaking change but an improvement over previous behavior as it prevents unexpected behavior like
Element('O/S') in comp
returningFalse
which caused MP 2020 correction scheme to not apply oxide/sulfide corrections ifcomp
has oxidation states (see #3185).I added unit tests for all edge cases incl.
DummySpecies
: