Conversation
|
See also #1223 (comment) before merging... maybe keep group reprs simpler than before but make sure that |
|
Hi, I'm happy to finish up this PR. If I understood this correctly, what's missing is defining a |
|
Yes relative to current develop branch
…On Wed, 1 Mar 2017, 5:30 p.m. Juan Eiros, ***@***.***> wrote:
Hi,
I'm happy to finish up this PR. If I understood this correctly, what's
missing is defining a __str___ method in the GroupBase class that is
smart and only prints the first and last three elements when it's longer
than 10?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1222 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI0jB7P0GeEnUoGNkj_5_-ZvZkDLF5bZks5rhatCgaJpZM4MOay8>
.
|
|
I've got something that is sort of working, implemented in the def __str__(self):
name = self.level.name
if len(self) <= 10:
return '<{}Group {}>'.format(name.capitalize(), repr(list(self.level)))
else:
return '<{}Group {}, ..., {}>'.format(name.capitalize(),
repr(list(self.level)[:3])[:-1],
repr(list(self.level)[-3:])[1:])My guess is something like this is what you want: repr(rg)
>>> '<ResidueGroup with 10 residues>'
str(rg)
>>> <ResidueGroup [<Residue MET, 1>,
<Residue ARG, 2>,
<Residue ILE, 3>,
...,
<Residue ALA, 8>,
<Residue PRO, 9>,
<Residue GLY, 10>]>So that the |
|
Actually, changing |
|
Yeah that looks like a good start. Tests too!
…On Wed, 1 Mar 2017, 6:17 p.m. Juan Eiros, ***@***.***> wrote:
I've got something that is sort of working, implemented in the GroupBase
class. It's like this:
def __str__(self):
name = self.level.name
if len(self) <= 10:
return '<{}Group {}>'.format(name.capitalize(), repr(list(self.level)))
else:
return '<{}Group {}, ..., {}>'.format(name.capitalize(),
repr(list(self.level)[:3])[:-1],
repr(list(self.level)[-3:])[1:])
My guess is something like this is what you want:
repr(rg)>>> '<ResidueGroup with 10 residues>'str(rg)>>> <ResidueGroup [<Residue MET, 1>,
<Residue ARG, 2>,
<Residue ILE, 3>,...,
<Residue ALA, 8>,
<Residue PRO, 9>,
<Residue GLY, 10>]>
So that the repr from the individual elements that form the group are
printed out.
But what would be the equivalent of self.segments or self.residues in the
GroupBase class? Or is that not accessible from there, since ResidueGroup,
AtomGroup and SegmentGroup inherit from it?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1222 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI0jB9IzTfTSHHfNOLWpa3_mjYwONJ8tks5rhbWWgaJpZM4MOay8>
.
|
| self._ix = ix | ||
| self._u = u | ||
|
|
||
| def __repr__(self): |
There was a problem hiding this comment.
We are probably going to go back to the terse representation, see #1223 and comments therein.
|
|
||
| assert_raises(TypeError, self.ag.center, weights) | ||
|
|
||
| def test_representations(): |
|
I actually just have finished writing the tests, where should I do the PR so you can start looking at it? |
|
Ah sorry, I see. I'll do a new PR referencing #1223 |
Fixes #1221
Changes made in this Pull Request:
PR Checklist