pymatgen
pymatgen copied to clipboard
Bug fix: change CifWriter to save only the element symbol, and not the entire species string
Change the "atom site type symbol", such that the element symbol is saved instead of the full species string (which includes site properties). This fixes Issue #3065, allowing for accurate writing of structures containing species properties to CIF and MCIF files.
Summary
Major updates:
Change the "atom site type symbol", such that the element symbol is saved instead of the full species string (which includes site properties).
Todos
Checklist
Ensure:
- [ ] Google format doc strings added. Check with
ruff. - [ ] Type annotations included. Check with
mypy. - [ ] Tests added for new features/fixes.
- [ ] All tests and linting pass.
@kamronald does this still handle species with oxidation state correctly?
@mkhorton good point, I just checked and it does not handle them properly, I'll fix that
@mkhorton oxidation states are now properly saved
Thanks @kamronald! 👍
IIUC @mkhorton in https://github.com/materialsproject/pymatgen/issues/3065#issuecomment-1593845643, he's suggesting we continue saving scalar magmoms to regular CIF using the local data name mp registered here https://www.iucr.org/cgi-bin/cifreserve.pl.
Also, would be great if you could refactor your repro https://github.com/materialsproject/pymatgen/issues/3065#issuecomment-1593523071 into a new test case.
@janosh @mkhorton Yes will work on that
Codecov Report
Patch coverage: 100.00% and project coverage change: -0.57% :warning:
Comparison is base (
a1c19db) 74.65% compared to head (324a675) 74.09%.
Additional details and impacted files
@@ Coverage Diff @@
## master #3071 +/- ##
==========================================
- Coverage 74.65% 74.09% -0.57%
==========================================
Files 230 230
Lines 69377 69382 +5
Branches 16154 16154
==========================================
- Hits 51796 51410 -386
- Misses 14513 14937 +424
+ Partials 3068 3035 -33
| Files Changed | Coverage Δ | |
|---|---|---|
| pymatgen/io/cif.py | 92.21% <100.00%> (+0.04%) |
:arrow_up: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.