Skip to content
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

PEP8 fixes on backend_bases.py #1345

Merged
merged 2 commits into from Oct 11, 2012
Merged

PEP8 fixes on backend_bases.py #1345

merged 2 commits into from Oct 11, 2012

Conversation

NelleV
Copy link
Member

@NelleV NelleV commented Oct 9, 2012

Pep8 fixes on the module backend_bases

return width, height, descent

flags = self._text2path._get_hinting_flag()
font = self._text2path._get_font(prop)
size = prop.get_size_in_points()
font.set_size(size, dpi)
font.set_text(s, 0.0, flags=flags) # the width and height of unrotated string
font.set_text(
s, 0.0, flags=flags) # the width and height of unrotated string
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it aids readability for a comment to cause an otherwise short statement to be split like this.
Alternatives: put the comment on a separate line (below, indented), or shorten the comment, e.g., "width, height of unrotated string".

@NelleV
Copy link
Member Author

NelleV commented Oct 9, 2012

Updated with a new patch.

@@ -364,7 +369,8 @@ def _iter_collection(self, gc, master_transform, all_transforms,
xo, yo = toffsets[i % Noffsets]
if offset_position == 'data':
if Ntransforms:
transform = all_transforms[i % Ntransforms] + master_transform
transform = all_transforms[
i % Ntransforms] + master_transform
Copy link
Member

Choose a reason for hiding this comment

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

I think you should break this line at the +.

Copy link
Member

Choose a reason for hiding this comment

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

@NelleV I agree with @dmcdougall that this is a bad break; with parentheses you could follow his suggestion.

@dmcdougall
Copy link
Member

I'll have a think about those list comprehensions, but other than that I'm giving this my +1.

@dmcdougall
Copy link
Member

Excellent! Thanks @NelleV.

Affine2D().scale(1./self.figure.dpi))
bbox_inches1 = TransformedBbox(
_bbox,
Affine2D().scale(1. / self.figure.dpi))

bbox_inches = Bbox.union([bbox_inches, bbox_inches1])
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion:

trans = Affine2D().scale(1.0 / self.figure.dpi)
bbox_inches1 = TransformedBbox(_bbox, trans)

@dmcdougall
Copy link
Member

@efiring Thanks for your input on this. When you're happy, make it known.

@dmcdougall
Copy link
Member

@NelleV When you've implemented @efiring's suggestion, could you squash all these to a single commit?

@NelleV
Copy link
Member Author

NelleV commented Oct 10, 2012

It's done

@dmcdougall
Copy link
Member

@NelleV Cheers. The Hawaiians are sleeping at the moment, so we'll wait a little bit to get Eric's approval.

path, transform = path_id
transform = transforms.Affine2D(transform.get_matrix()).translate(xo, yo)
transform = transforms.Affine2D(
transform.get_matrix()).translate(xo, yo)
Copy link
Member

Choose a reason for hiding this comment

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

In all the examples like this, I would favor using more indentation for the second line, perhaps aligning it with the start of the RHS of the line above. This would make it more visually obvious that it is a continuation of the line above, not an independent line in a block.

'raw': 'Raw RGBA bitmap',
'rgba': 'Raw RGBA bitmap',
'svg': 'Scalable Vector Graphics',
'svgz': 'Scalable Vector Graphics'
}
'svgz': 'Scalable Vector Graphics'}
Copy link
Member

Choose a reason for hiding this comment

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

Actually, I have found it to be better to end lists and dictionaries like this with the last element having a comma and putting the closing brace or bracket on its own line. This makes for fewer merge conflicts as it is easier for patch to handle any edits to such a list of things. Of course, that is merely my own opinion.

Copy link
Member

Choose a reason for hiding this comment

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

That's sensible.

efiring added a commit that referenced this pull request Oct 11, 2012
@efiring efiring merged commit 74c74d5 into matplotlib:master Oct 11, 2012
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.

None yet

6 participants