👌 PseudoPotentialData: Improve string representation#197
Merged
Conversation
The `PseudoPotentialData` is currently missing a `get_description` method, which means this returns the default empty string derived from the `Node` class. The default `__repr__` method also does not show one of the most important attributes of the `PseudoPotentialData` class: the element it represents. Here we add the `__repr__` and `get_description` methods to the `PseudoPotentialData` class. Although these could (and perhaps should) serve a different purpose, we don't want users to be confused when they see a difference between: * the pseudos dictionary returned by `builder.pseudos`, which uses `__repr__`. * The `__repr_pretty__` method of the `ProcessBuilder`, which uses `get_description` for `Node` objects. Hence, we make them return the same output by having the `get_description` method call `repr`. For the contents, we choose to add: * The class name, so they can see the type of pseudopotential. * The element of the pseudopotential. * The PK of the pseudpotential node. We skip the UUID to reduce the noise. In most local usage the PK is much more common, and the user can still easily get the UUID using `node.uuid`.
Member
Author
|
Example usage from from aiida import orm, load_profile
load_profile()
from ase.build import bulk
from aiida_quantumespresso.calculations.pw import PwCalculation
structure = orm.StructureData(ase=bulk('Si', 'fcc', 5.43))
pseudo_family = orm.load_group('SSSP/1.3/PBEsol/efficiency')
builder = PwCalculation.get_builder()
builder.pseudos = pseudo_family.get_pseudos(structure=structure)
builderreturns Process class: PwCalculation
Inputs:
metadata:
options:
stash: {}
unstash: {}
monitors: {}
pseudos:
Si: '<UpfData[Si] (pk: 72)>'Note that I also adapt the builder.pseudosreturns {'Si': <UpfData[Si] (pk: 72)>} |
t-reents
approved these changes
Sep 23, 2025
Collaborator
t-reents
left a comment
There was a problem hiding this comment.
I hope I have the permissions 😄
Thanks for quickly fixing it, I think that this is indeed very useful for users (especially new ones).
Collaborator
Damn, I don't. Sorry @mbercx for not being helpful 😄 |
Member
Author
|
Check your inbox 😉 |
Collaborator
|
Worked |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
PseudoPotentialDatais currently missing aget_descriptionmethod, which means this returns the default empty string derived from theNodeclass. The default__repr__method also does not show one of the most important attributes of thePseudoPotentialDataclass: the element it represents.Here we add the
__repr__andget_descriptionmethods to thePseudoPotentialDataclass. Although these could (and perhaps should) serve a different purpose, we don't want users to be confused when they see a difference between:builder.pseudos, which uses__repr__.__repr_pretty__method of theProcessBuilder, which usesget_descriptionforNodeobjects.Hence, we make them return the same output by having the
get_descriptionmethod callrepr. For the contents, we choose to add:We skip the UUID to reduce the noise. In most local usage the PK is much more common, and the user can still easily get the UUID using
node.uuid.