emmet icon indicating copy to clipboard operation
emmet copied to clipboard

el_refs serialized as strings

Open jmmshn opened this issue 2 years ago • 5 comments

https://github.com/materialsproject/emmet/blob/31a226297f3677098e61da13b8e7fe4ea6177fdd/emmet-core/emmet/core/thermo.py#L251-L253

When these PhaseDiagramDocuments are pulled from the DB and deserialized the keys for el_refs are string but the pymatgen code uses Element the entries time. I can't find if a conversion occurred in emmet.

pd = loadfn("/Users/shen9/Desktop/pd_doc.json") # taken from DB
pd["phase_diagram"].el_refs.keys()
# gives dict_keys(['O', 'Ge', 'Co', 'Li'])

@kim-jiyoon reported this. @munrojm and @mkhorton can you please have a look? This is to get the conversion documents on the new site.

jmmshn avatar Oct 27 '22 03:10 jmmshn

Yup! Will take a look at this.

munrojm avatar Oct 27 '22 21:10 munrojm

@janosh, this seems to stem from the fact that computed_data can be passed when constructing a PhaseDiagram object, which contains the el_refs dictionary. If its keys are strings instead of Element objects it appears to make a fuss when de-serializing with monty, or when trying to plot with PDPlotter. It might be best to have it check and ensure Element object keys on construction in pymatgen?

munrojm avatar Jan 19 '23 23:01 munrojm

Also, qhull_data is assumed to be a numpy array, and causes similar issues for ternary+ plots. For now, I am manually patching in the API client. https://github.com/materialsproject/api/blob/ece1b3effeebae208a16d98776a3bb555ec8e459/mp_api/client/routes/thermo.py#L181

munrojm avatar Jan 20 '23 00:01 munrojm

Was I tagged by accident?

janosh avatar Jan 20 '23 02:01 janosh

@janosh No, this just relates to a pymatgen issue I was about to open. We can discuss outside of this thread.

munrojm avatar Jan 20 '23 02:01 munrojm