Skip to content

Add properties @property/docstring to IStructure #3338

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

Merged
merged 10 commits into from
Sep 17, 2023

Conversation

mkhorton
Copy link
Member

Addendum to #3264, notifying @gpetretto, @janosh.

Two things I think we missed in #3264:

  • A formal @property so that we get a docstring for the new IStructure.properties
  • An edge-case for backwards compatibility. While I strongly recommend people do not use pickle as an archival format, nevertheless this is a very core pymatgen class, and I don't want to break people's workflows if they upgrade. Specifically, if you pickle a Structure from a previous pymatgen version, and then un-pickle it with the new pymatgen version, the __init__ will not be called, so the .properties instance variable is never set: this will then break code that relies upon it, like as_dict(). Luckily, adding the @property interface allows us to trivially catch this edge case.

mkhorton and others added 6 commits September 17, 2023 12:29
Note that the arg/variable name is "structure", but often dealing with molecules here; maybe more correctly would be called "site_collection". A lot of the code inside the adaptor is a little awkward as a result.
@mkhorton
Copy link
Member Author

Adding a note that, while reviewing this, I noticed a lot of methods on SiteCollection reference a "structure", even though these methods are also used by IMolecule/Molecule. Might cause some confusion.

Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! 👍

@mkhorton mkhorton merged commit 34cb397 into master Sep 17, 2023
@mkhorton mkhorton deleted the mkhorton/structure-properties-patch branch September 17, 2023 23:22
@mkhorton mkhorton added the fix Bug fix PRs label Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants