Repository navigation
Add properties to Structure and Molecule - #3264
Conversation
|
Thanks @gpetretto for taking this on! Looks promising. 👍 I think we need better file IO support before merging. Right now, the properties are written to JSON json_str = struct_with_props.to(fmt="json")
assert '"test_property": 42' in json_strbut they're not read back in struct = Structure.from_str(json_str, fmt="json")
assert struct.properties == propsAs I mentioned in #2884 (comment) it would be nice to retain properties when reading and writing to as many file formats as possible. JSON at least is easy to do. |
|
@arosen93 @utf Would you mind taking a look at this to ensure it addresses your use cases? |
|
At a very quick glance, this seems reasonable. Once merged, I will need to update the ASE atoms adapter to ensure this is handled nicely. But that's for me to deal with. |
…he structure to JSON or YAML but is
lost when converting to other formats.
|
Thanks @gpetretto! 👍 |
|
@gpetretto: Any thoughts about (de)serialization with the new d = jsanitize(structure, strict=True, enum_values=True)
MontyDecoder().process_decoded(d) |
|
Good question! Not obvious what's the best solution here. We could issue a silenceable runtime warning when users set non-JSONable |
|
This is a good point. I actually did not think much about this kind of problems since in my view |
Closes #2884.
This PR implements a
propertiesattribute forStructureandMolecule. I also modified thePoscarobject to store thepredictor_corrector_preamblein the structure properties.