Skip to content

Apply Yapf to AtomGroup.py #393

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

Closed
wants to merge 1 commit into from
Closed

Conversation

kain88-de
Copy link
Member

with default settings (PEP8 style).

@@ -546,7 +552,9 @@ def position(self):

:Returns: a (3,) shape numpy array
"""
return self.universe.coord.positions[self.index] # internal numbering starts at 0
return self.universe.coord.positions[
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line change is only done because of the trailing comment. Converting this into a normal comment in the above line will make yapf behave better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that can be turned off.

@richardjgowers richardjgowers self-assigned this Aug 19, 2015
@dotsdl
Copy link
Member

dotsdl commented Aug 20, 2015

I'm a bit confused. What issue is this PR addressing? Can you add a link and give a bit of explanation?

@richardjgowers
Copy link
Member

https://groups.google.com/forum/#!topic/mdnalysis-devel/WjM0SN9gWFA

It's to do with trying to solidify the style a bit more.

It's not terrible, but in some places it's made it worse, and in others it's just replaced one flavour of ugly with another. I think with stuff like this you're always going to want to run it through a diff tool and accept/reject the proposed changes.

@kain88-de
Copy link
Member Author

Yes. Curiously in this file it even did a wrong transformation because the code wasn't PEP8 compliant
in the first place (see the failed test).

Another approach which I have seen used in other old projects is to agree upon a style and then fix things as you go along. In all my current PR's I fix the warnings from flake8 for the functions I touch and leave the rest of the files alone. This takes longer until we would have a consistent style but we are also sure not to break things as we go along.

I have my editor (emacs + elpy) set to highlight all lines containing syntax and formatting errors. Since the formatting errors are quite annoying to see this I have a personal motivation here to fix them.


for a1, a2 in bonds: # Iterate through all bonds
if not (f[a1] or f[a2]): # New set made here
new = _fragset([a1, a2])
f[a1] = f[a2] = new
elif f[a1] and not f[a2]: # If a2 isn't in a fragment, add it to a1's
elif f[a1] and not
f[a2]: # If a2 isn't in a fragment, add it to a1's
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I noticed that yapf doesn't like these trailing comments. This is also the reason why some of the formatting comes out weird.

@orbeckst orbeckst mentioned this pull request Aug 28, 2015
11 tasks
I changed the style a little bit to better represent what
currently is in this file.
@kain88-de
Copy link
Member Author

I tried changing the default style a little bit. It looks better to me but I still don't know why it splits the named assigns, tough I can live with it.

@richardjgowers
Copy link
Member

I'm gonna kill this, I think we've kinda addressed this in #404

@kain88-de kain88-de deleted the yapf branch September 12, 2015 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants