PatchedPhaseDiagram mimic PhaseDiagram Serialization#4541
PatchedPhaseDiagram mimic PhaseDiagram Serialization#4541shyuep merged 14 commits intomaterialsproject:masterfrom
Conversation
72688df to
094e201
Compare
|
This does make some breaking changes to #4414 as some of the objects there were left hydrated after as_dict and this also changes that behavior for the PhaseDiagram. |
|
examples of code and new outputs from pprint import pprint
from pymatgen.analysis.phase_diagram import PatchedPhaseDiagram, PhaseDiagram, PDEntry
from pymatgen.core.composition import Composition
# %%
entries = [
PDEntry(Composition("Li"), energy=-1.0),
PDEntry(Composition("O2"), energy=-6.0),
PDEntry(Composition("Li2O"), energy=-12.0),
PDEntry(Composition("LiO2"), energy=-9.0),
PDEntry("He", -1.23)
]
# %%
pd = PhaseDiagram(entries)
ppd = PatchedPhaseDiagram(entries)
# %%
pd_dict = pd.as_dict()
pprint(pd_dict)
# %%
ppd_dict = ppd.as_dict()
pprint(ppd_dict) |
|
Thanks. We have refactored pymatgen to move core packages to a separate pymatgen-core repo. If you don't mind, can you fix the merge conflicts and if necessary, put some of the changes in pymatgen-core pls? Thanks. |
|
Okay great! this should be able to be merged now. The changes to core were mostly unrelated typing consistency things and so have just discarded them from this PR. |
|
Thanks! |
| Yb: 31 | ||
| Zn: 70 | ||
| Coefficient of linear thermal expansion: | ||
| reference: "https://en.wikipedia.org/wiki/Thermal_expansivities_of_the_elements" # WEL |
There was a problem hiding this comment.
I think here we should add this file to codespell exclude list instead:
pymatgen/.pre-commit-config.yaml
Line 38 in 9d1de13
This comment was added because that wiki page might have multiple sources for certain entries (without use field), so it was added to make sure people know the actual source used, for example:
Maybe I should have added a description field to explain this better...
Summary
This avoids the duplication of data when loading a ppd as so allows for serialization to text which is much more robust than using pickle.
Attempts to type hint phase diagrams better hence touching more files to get mypy consistency.
#3940 #4414
Checklist
ruff.mypy.duecredit@due.dcitedecorators to reference relevant papers by DOI (example)Tip: Install
pre-commithooks to auto-check types and linting before every commit: