pymatgen icon indicating copy to clipboard operation
pymatgen copied to clipboard

Bug fix: change CifWriter to save only the element symbol, and not the entire species string

Open kamronald opened this issue 2 years ago • 6 comments

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 avatar Jun 15 '23 23:06 kamronald

@kamronald does this still handle species with oxidation state correctly?

mkhorton avatar Jun 15 '23 23:06 mkhorton

@mkhorton good point, I just checked and it does not handle them properly, I'll fix that

kamronald avatar Jun 15 '23 23:06 kamronald

@mkhorton oxidation states are now properly saved

kamronald avatar Jun 16 '23 00:06 kamronald

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 avatar Jun 16 '23 06:06 janosh

@janosh @mkhorton Yes will work on that

kamronald avatar Jun 16 '23 17:06 kamronald

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:

... and 6 files with indirect coverage changes

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Aug 18 '23 18:08 codecov-commenter