-
Notifications
You must be signed in to change notification settings - Fork 658
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
change return type of 'translate','rotate' to allow chaining of these functions. #1010
Comments
Btw we have to be very careful with such a change because it will likely break a lot of user code. |
So, basically, |
@jbarnoud yes. |
From what I can see, they just return the transformation you applied to them, which is usually known as it was an argument.... Can this be done onto the 363 branch to avoid any regressions? |
I think so. But I saying again that this change will likely break user code. So I would be careful with it. |
@orbeckst what do you think about this change. Your are mostly a reasonable user-voice if we should do an API-break. BTW if we do this I would use one/two versions that displays a warning that the return type of these functions will change and that scripts shouldn't rely on it. |
This is a good suggestion and makes more sense than the current behavior. (History: The reason for returning the argument was that the arguments can be processed, for instance, |
We could add a warning but we can't fix any code. |
Expected behaviour
I wish I could do things like
ag.translate(-ag.center_of_mass()).rotate(R).positions
.It is a nice chain of operations that is also very readable. Or another thing which I tried and failed is
[ag.translate(-ag.center_of_mass()).positions for ag in list]
Actual behaviour
They fail because both
translate
androtate
don't return the modified AtomGroup but rather the object used to modify it.Currently version of MDAnalysis:
(run
python -c "import MDAnalysis as mda; print(mda.__version__)"
)0.15.1-dev0
The text was updated successfully, but these errors were encountered: