-
Notifications
You must be signed in to change notification settings - Fork 666
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
AtomGroup API: convert some methods to properties #372
Comments
yes, much less typing; cleaner code, more Pythonic ... and because all other packages use python PS: summer is almost gone and I am still waiting for @richardjgowers for his py3. ha ha. |
and |
So I'm in favour of properties for 0.11.0. Letting the setters also be callable does let you specify extra arguments.. so we could do atomgroup.set_resid([0, 1, 2, 3], fancy_option=True) But currently I think it's only It's difficult to mitigate pain, but a script should be easy enough. With I would expect: # This returns len(atomgroup)
# because I'm working on atoms
atomgroup.resids = [0, 0, 1, 1, 1, 2, 2]
# This returns len(residuegroup)
# because I'm working on residues
residuegroup.resids = [0, 1, 2] There's some The other thing we had briefly discussed was moving away from camelCase. This would then entail atomgroup.selectAtoms -> atomgroup.select_atoms This is big, but it's painless as we can keep selectAtoms as deprecated. |
I'd like to add a request for an Atom-property-to-AtomGroup-properties dictionary, so that selections for It should be easy, and it's mostly the plural of names ( Maybe with @richardjgowers's new |
So you mean somewhere there's a dict like PLURALS = {'radius':'radii', etc
SINGLES = {'radii':'radius' etc (can do this as a dict inversion of previous |
Exactly. Then in the Selection module we don't even need explicit lists of selectable attributes. We simply try It's not as straightforward, since different attributes will need different selection comparison methods (less so when they all become fields in a structured array), but it's a start to making selections more general and clean up code duplication. |
So another thing I've found, atoms have the |
I'd vote for introducing Atom.index and deprecating number (which probably comes from CHARMM historically and should also be reflected in the selection syntax). Oliver Beckstein Am Jul 29, 2015 um 13:37 schrieb Richard Gowers [email protected]:
|
I've pushed a branch that does everything proposed so far. TODO:
@mnmelo I've added your dict to core/AtomGroup as below. If it prevents a circular import this can be moved to somewhere else.
|
I'm very much in favor of this, especially making a one-to-one correspondence between AtomGroup and Atom properties and ResidueGroup and Residue properties. One thing I would change from its current behavior is |
On 31 Jul, 2015, at 15:50, David Dotson wrote:
Personally, I would find it very annoying of AtomGroup.resids gave me one resid per atom. Most of the time I use it to figure out the resids in the group. Having to do a np.unique(AtomGroup.resids) or AtomGroup.residues.resids (?) every time seems a bit cumbersome (and I am not even sure if the latter does what I'd want it to do). The same goes for AtomGroup.segids, by the way. So in that sense there's more than one property that will not return the size of the AG. On the other hand, there's something to be said for consistency, so any idea how to have the cake and eat it, too? Or does no-one else need the convenience? |
Doesn't [atom.resid for atom in atomgroup] to get them. That's what I'd call cumbersome. Since the current behavior can be obtained with |
Not to appeal to the Zen of Python, but I think:
|
@dotsdl , please open a new issue for sorting out the size of the returned arrays for Just summarize (copy & paste...) the state of the discussion. |
@hainm , please open (or re-open if there was alreay an issue) your suggestion to change |
@richardjgowers , I merged #374 because the sooner we start switching over the better (if the developers cannot deal with the change then users will have a really hard time..) but I think not everything from you checklist was completed, in particular using the property setters is not being tested for and the docs have not been adjusted. We will close this issue when these points have been addressed. |
@richardjgowers , please open a new issue for changing The other thing we had briefly discussed was moving away from camelCase. This would then entail atomgroup.selectAtoms -> atomgroup.select_atoms This is big, but it's painless as we can keep |
Sure. I will. Hai
|
Ok will do. |
@richardjgowers , can you close this issue? Did you address the remaining points from your checklist, in particular testing the property setters and have the docs been adjusted (perhaps @tylerjereddy knows this, i.e. #382 ). |
@richardjgowers finishing this up today, by hook or by crook. :D |
We should discuss if we also want to break the AtomGroup API with 0.11.0, as discussed on and off on the developer list (@richardjgowers , @mnmelo ): request for discussion: changing parts of AtomGroup API. A number of methods of AtomGroup are really conceptually more attributes (typically, quantities derived from the topology) so a good case can be made to turn them into managed properties. (I cannot remember if there was a specific rationale in the early days why they were methods – maybe @nmichaud remembers...?)
The 0.11.0 release would be a (comparatively) good time because other stuff changes, too, and if users need to rework their code then they should really only have to do it once. (Users will hate the changes outlined here because they will break code in cryptic ways and I don't see a way to have the same method and property co-exist for a while.)
I'd like to open a discussion with a focus on
Proposal
Turn methods that mainly report on topology properties into managed attributes.
For example:
Provide setters when possible and replace the corresponding
set_*
methods:AtomGroup methods to be changed
I suggest the following methods to be converted to managed attributes:
The text was updated successfully, but these errors were encountered: