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 Compositionis currentlyFalseif thatElementappears inCompositionas aSpecieswith an oxidation state.This PR changes the
__contains__method to returnTrueforx in Compositionifxexactly matches aSpecies(both element symbol and oxidation state) in the composition (same as before)xis anElementand aSpecieswith matching element symbol is present, regardless of oxidation state (returnedFalsebefore).It does not change behavior for the reverse, i.e. if a
Species in Compositionis stillFalseif only itsElementwithout 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 compreturningFalsewhich caused MP 2020 correction scheme to not apply oxide/sulfide corrections ifcomphas oxidation states (see #3185).I added unit tests for all edge cases incl.
DummySpecies: