-
Notifications
You must be signed in to change notification settings - Fork 868
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
Modified CifParser.check() as one possible solution for issue #3626 #3628
Conversation
|
…y in case of missing formula keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @kaueltzen, this makes sense! also great issue description over in #3626!
if you could add a test with the MCIF file you linked in the issue (or find an existing CIF test file that repros this problem), this is good to go.
pinging @esoteric-ephemera in case he has further comments
pymatgen/io/cif.py
Outdated
if not same_stoich: | ||
failure_reason = f"Incorrect stoichiometry:\n CIF={orig_comp}\n PMG={struct_comp}\n {ratios=}" | ||
else: | ||
self.warnings.append("Skipping relative stoichiometry check because CIF does not contain formula keys.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a test for this warning?
Thanks @kaueltzen for pointing this out! I like your solution of warning that the stoichiometry check couldn't be accomplished - the fallback I added originally clearly isn't robust enough in general Adding a test for this (using the magnetic cif you sent with the issue) would be great to move this forward |
…e of missing formula keys and for appending a warning to self.warnings in this case.
Thank you for your quick replies! I added a test both for skipping the relative stoichiometry check and appending a warning in the case of missing formula keys. There was already a test file in pymatgen, Li10GeP2S12.cif, that matched the criteria (it has no formula keys and sites with different multiplicities and occupancies). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice work! thanks a lot @kaueltzen 👍
closes #3626.
CifParser.check()
raises aUserWarning: Incorrect stoichiometry
for a cif, if_chemical_formula_sum
and_chemical_formula_structural
are missing andFor the relative stoichiometry to be checked correctly, the site multiplicities would have to be included by applying the cif's symmetry operations to the crystallographically unique sites (like for construction for the structure).
As this would be no longer a sanity check, i propose skipping the relative stoichiometry check in this case (but still including all the other checks for valid elements etc.).
For the case of skipping the relative stoichiometry check, i appended a message to
self.warnings
, but I'm not sure if there are better ways to handle this case.