Skip to content
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

Make it clear distinction Mutable or not, and clear error messages #48

Closed
6 tasks done
mikibonacci opened this issue Oct 10, 2024 · 1 comment · Fixed by mikibonacci/aiida-atomistic#5
Closed
6 tasks done
Assignees

Comments

@mikibonacci
Copy link
Collaborator

mikibonacci commented Oct 10, 2024

We should provide

  • clear and exhaustive error messages when immutablity creates exceptions (i.e. we try to modify immutable structures)
  • When the aiida-atomistic is imported into aiida-core, make it clear exceptions if the package is not found (stating that the user needs to install it and so on)
  • .get_value() methods instead of to_mutable.
  • For the viceversa, just put a class method in the StructureData which is from_mutable or something like that.
  • in passing by, fix the get_defined_properties (see the DFT+U example in notebook 3, the method does not show the magmoms.)
  • Update the documentation and the tests! mainly the get_value and from_mutable methods.
@mikibonacci mikibonacci self-assigned this Oct 10, 2024
mikibonacci added a commit to mikibonacci/aiida-atomistic that referenced this issue Nov 19, 2024
This fixes aiidateam#48

* Make it clear distinction Mutable or not, and clear error messages

* Fixing the get_defined_properties method.

* Fixing tests

* removing the `to_immutable` method from the docs.

* Small fix for DFT+U example and from_pymatgen detect_kinds.

* Small modification to immutability sentences

* Test for sites immutability.
@mikibonacci
Copy link
Collaborator Author

Just to mention where I improve this. For example, I modified the __setattr__ of the StructureData:

def __setattr__(self, key, value):
        # Customizing the exception message when trying to mutate attributes
        if key in self.__fields__:
            raise ValueError("The AiiDA `StructureData` is immutable. You can create a mutable copy of it using its `get_value` method.")
        super().__setattr__(key, value)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant