-
Notifications
You must be signed in to change notification settings - Fork 871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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_str but they're not read back in struct = Structure.from_str(json_str, fmt="json")
assert struct.properties == props As 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
properties
attribute forStructure
andMolecule
. I also modified thePoscar
object to store thepredictor_corrector_preamble
in the structure properties.