-
Notifications
You must be signed in to change notification settings - Fork 15
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
replace full output info in __str__ by chemical formula #439
Conversation
Pull Request Test Coverage Report for Build 1516586052
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this solution. In my notebook testing nothing changes on just providing a structure, since the notebook ignores __str__
and uses __repr__
. Just if you print(structure)
you just get the chemical formula.
I see how this is useful, but I also think it's nice to have just the text dump of a structure, especially when checking small structures. |
Is there a case that |
On |
Maybe we replace |
But I still don't understand what would make you use |
I am not sure if we would need this. With this change we would get after all: Fe = pr.create.structure.bulk('Fe')
Fe
>>> Fe: [0. 0. 0.]
>>> pbc: [ True True True]
>>> cell:
>>> Cell([[-1.435, 1.435, 1.435], [1.435, -1.435, 1.435], [1.435, 1.435, -1.435]])
# same as `print(repr(Fe))` only print(Fe)
>>> Fe
str(Fe)
>>> 'Fe' would change. The only reason for a |
Yes, it's exactly as you say, Niklas. I am also not immediately sure what the application might be for needing the full string, but I share Marvin's reticence for getting rid of it entirely. It clutters the namespace a little bit, but I'd be more comfortable if we kept the string accessible by a special method. Otherwise installs like the change in the default behaviour |
I am ok with adding that method, however, if I really needed that string I could just do |
If we don't know whether |
Following today's pyiron meeting, I'll merge this one as soon as the tests pass. |
In order to exploit the feature here, I would like to suggest to largely simplify
__str__
inAtoms
by replace the full info by the chemical formula. this allows us to set something like: