8000 [examples] final pep8 fixes by twmr · Pull Request #3774 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

[examples] final pep8 fixes #3774

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

Merged
merged 26 commits into from
Nov 15, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5cba226
fix trailing whitespace
twmr Nov 9, 2014
8cae397
fix multiple whitespace issues in svg_*.py examples (E293, E291)
twmr Nov 9, 2014
2f5b1e1
pep8 fix E201
twmr Nov 9, 2014
cc7fc7f
pep8 fix e2* in examples dir part 1/2
twmr Nov 9, 2014
b680680
pep8 fix e2* in examples dir part 2/2
twmr Nov 9, 2014
b081c92
pep8 fix E701
twmr Nov 9, 2014
0130bb9
pep8 fix E502 (redundant backslash)
twmr Nov 9, 2014
b959c79
pep8 fix e702,e703
twmr Nov 9, 2014
7122484
pep8 fix E302
twmr Nov 9, 2014
fa2ee50
remove blacklisted examples from coding style unittest
twmr Nov 9, 2014
eef2efc
ignore line to long errors for pep8 unit tests in examples/
twmr Nov 9, 2014
6289558
pep8 fix E124-E129
twmr Nov 9, 2014
16e1566
pep fix E401
twmr Nov 9, 2014
1e822e9
fix all issues in the output of the pep8 unit test
twmr Nov 9, 2014
85519f0
decrease the number of ignored pep8 error classes
twmr Nov 9, 2014
111cdab
consider @weathergods suggestions
twmr Nov 9, 2014
192a26c
prettify instantiation of ellipsecollection object
twmr Nov 9, 2014
e53ba3e
avoid triple quoted string
twmr Nov 9, 2014
3bd0f57
fix mutable default arguments
twmr Nov 9, 2014
2da662b
don't use implicit tuple assignment
twmr Nov 9, 2014
cb0467d
prettify instantiation of Linecollection obj even further
twmr Nov 9, 2014
2cb5403
Revert "pep8 fix E201"
twmr Nov 10, 2014
a79053c
fix pep8 unit tests
twmr Nov 15, 2014
9591cb8
minor cleanup in pipong example (0 + value)
twmr Nov 15, 2014
eab5b52
fixed extraneous whitespace
twmr Nov 15, 2014
2303939
fix pep8 violations in the new boxplot examples
twmr Nov 15, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pep8 fix E201
  • Loading branch information
twmr committed Nov 15, 2014
commit 2f5b1e17e2d286a39127a8c9586200ce788c02aa
8000
10 changes: 5 additions & 5 deletions examples/pylab_examples/table_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import matplotlib.pyplot as plt


data = [[ 66386, 174296, 75131, 577908, 32015],
[ 58230, 381139, 78045, 99308, 160454],
[ 89135, 80552, 152558, 497981, 603535],
[ 78415, 81858, 150656, 193263, 69638],
[ 139361, 331509, 343164, 781380, 52269]]
data = [[66386, 174296, 75131, 577908, 32015],
[58230, 381139, 78045, 99308, 160454],
[89135, 80552, 152558, 497981, 603535],
[78415, 81858, 150656, 193263, 69638],
[139361, 331509, 343164, 781380, 52269]]

columns = ('Freeze', 'Wind', 'Flood', 'Quake', 'Hail')
rows = ['%d year' % x for x in (100, 50, 20, 10, 5)]
Expand Down
18 changes: 9 additions & 9 deletions examples/pylab_examples/tricontour_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
[-0.052, 1.022], [-0.052, 1.017], [-0.069, 1.010], [-0.064, 1.005],
[-0.048, 1.005], [-0.031, 1.005], [-0.031, 0.996], [-0.040, 0.987],
[-0.045, 0.980], [-0.052, 0.975], [-0.040, 0.973], [-0.026, 0.968],
[-0.020, 0.954], [-0.006, 0.947], [ 0.003, 0.935], [ 0.006, 0.926],
[ 0.005, 0.921], [ 0.022, 0.923], [ 0.033, 0.912], [ 0.029, 0.905],
[ 0.017, 0.900], [ 0.012, 0.895], [ 0.027, 0.893], [ 0.019, 0.886],
[ 0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879],
[-0.020, 0.954], [-0.006, 0.947], [0.003, 0.935], [0.006, 0.926],
[0.005, 0.921], [0.022, 0.923], [0.033, 0.912], [0.029, 0.905],
[0.017, 0.900], [0.012, 0.895], [0.027, 0.893], [0.019, 0.886],
[0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879],
[-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872],
[-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933],
[-0.077, 0.990], [-0.059, 0.993]])
Expand All @@ -72,11 +72,11 @@
z = np.exp(-0.01*((x-x0)*(x-x0) + (y-y0)*(y-y0)))

triangles = np.asarray([
[67, 66, 1], [65, 2, 66], [ 1, 66, 2], [64, 2, 65], [63, 3, 64],
[60, 59, 57], [ 2, 64, 3], [ 3, 63, 4], [ 0, 67, 1], [62, 4, 63],
[57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [ 4, 62, 68],
[ 6, 5, 9], [61, 68, 62], [69, 68, 61], [ 9, 5, 70], [ 6, 8, 7],
[ 4, 70, 5], [ 8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9],
[67, 66, 1], [65, 2, 66], [1, 66, 2], [64, 2, 65], [63, 3, 64],
[60, 59, 57], [2, 64, 3], [3, 63, 4], [0, 67, 1], [62, 4, 63],
[57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [4, 62, 68],
[6, 5, 9], [61, 68, 62], [69, 68, 61], [9, 5, 70], [6, 8, 7],
[4, 70, 5], [8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9],
[54, 53, 55], [56, 55, 53], [68, 70, 4], [52, 56, 53], [11, 10, 12],
[69, 71, 68], [68, 13, 70], [10, 70, 13], [51, 50, 52], [13, 68, 71],
[52, 71, 69], [12, 10, 13], [71, 52, 50], [71, 14, 13], [50, 49, 71],
Expand Down
18 changes: 9 additions & 9 deletions examples/pylab_examples/tripcolor_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@
[-0.052, 1.022], [-0.052, 1.017], [-0.069, 1.010], [-0.064, 1.005],
[-0.048, 1.005], [-0.031, 1.005], [-0.031, 0.996], [-0.040, 0.987],
[-0.045, 0.980], [-0.052, 0.975], [-0.040, 0.973], [-0.026, 0.968],
[-0.020, 0.954], [-0.006, 0.947], [ 0.003, 0.935], [ 0.006, 0.926],
[ 0.005, 0.921], [ 0.022, 0.923], [ 0.033, 0.912], [ 0.029, 0.905],
[ 0.017, 0.900], [ 0.012, 0.895], [ 0.027, 0.893], [ 0.019, 0.886],
[ 0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879],
[-0.020, 0.954], [-0.006, 0.947], [0.003, 0.935], [0.006, 0.926],
[0.005, 0.921], [0.022, 0.923], [0.033, 0.912], [0.029, 0.905],
[0.017, 0.900], [0.012, 0.895], [0.027, 0.893], [0.019, 0.886],
[0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879],
[-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872],
[-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933],
[-0.077, 0.990], [-0.059, 0.993]])
x = xy[:, 0]*180/3.14159
y = xy[:, 1]*180/3.14159

triangles = np.asarray([
[67, 66, 1], [65, 2, 66], [ 1, 66, 2], [64, 2, 65], [63, 3, 64],
[60, 59, 57], [ 2, 64, 3], [ 3, 63, 4], [ 0, 67, 1], [62, 4, 63],
[57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [ 4, 62, 68],
[ 6, 5, 9], [61, 68, 62], [69, 68, 61], [ 9, 5, 70], [ 6, 8, 7],
[ 4, 70, 5], [ 8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9],
[67, 66, 1], [65, 2, 66], [1, 66, 2], [64, 2, 65], [63, 3, 64],
Copy link
Member

Choose a reason for hiding this comment

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

You can leave your change as-is, if it makes the pep8 checker happy; but for the record, this is an example where the original is better, and I think entirely within the original spirit and meaning of PEP 8 as a whole.

Copy link
Member

Choose a reason for hiding this comment

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

On second thought, if there is any reasonable way to leave these in their original version, I think you should do so. At some point, one must simply resist the mindless tyranny of mechanical PEP 8 checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you that the original was (slightly) better. The benefit of this version is that I don't have to blacklist E201 'whitespace after ‘(‘' as a whole in the unit tests. What I could try is to only blacklist E201 for the files in 3ef582b

Copy link
Member

Choose a reason for hiding this comment

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

OK. I don't know where the blacklisting is done, so I don't know what the options really are. When you say "as a whole", does that mean for the examples, or does it mean throughout the codebase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The blacklisting is done in test_coding_standards.py. By 'as a whole' I just meant the examples - see https://github.com/matplotlib/matplotlib/pull/3774/files#diff-13006e1a4da2e47c3f768fdd0f2cfaebR279

Copy link
Member

Choose a reason for hiding this comment

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

throwing # noqa on the end of a line should exclude it from the pep8 checking.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting; but that would be ugly and would defeat the whole purpose, which should be to make the code as readable and pleasant to work with as possible.

Copy link
Member

Choose a reason for hiding this comment

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

As the person responsible for maintaining this file, I too would like this section to remain as it is.

There are other examples with the exact same block of numbers; they too should remain as they were.

Copy link
Member

Choose a reason for hiding this comment

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

@efiring by line, I mean expression, there should only need to be on # noqa which isn't too bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

# noqa doesn't work for all warnings/errors, see this issue PyCQA/pycodestyle#180. I'll try to come up with a different fix.

[60, 59, 57], [2, 64, 3], [3, 63, 4], [0, 67, 1], [62, 4, 63],
[57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [4, 62, 68],
[6, 5, 9], [61, 68, 62], [69, 68, 61], [9, 5, 70], [6, 8, 7],
[4, 70, 5], [8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9],
[54, 53, 55], [56, 55, 53], [68, 70, 4], [52, 56, 53], [11, 10, 12],
[69, 71, 68], [68, 13, 70], [10, 70, 13], [51, 50, 52], [13, 68, 71],
[52, 71, 69], [12, 10, 13], [71, 52, 50], [71, 14, 13], [50, 49, 71],
Expand Down
18 changes: 9 additions & 9 deletions examples/pylab_examples/triplot_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@
[-0.052, 1.022], [-0.052, 1.017], [-0.069, 1.010], [-0.064, 1.005],
[-0.048, 1.005], [-0.031, 1.005], [-0.031, 0.996], [-0.040, 0.987],
[-0.045, 0.980], [-0.052, 0.975], [-0.040, 0.973], [-0.026, 0.968],
[-0.020, 0.954], [-0.006, 0.947], [ 0.003, 0.935], [ 0.006, 0.926],
[ 0.005, 0.921], [ 0.022, 0.923], [ 0.033, 0.912], [ 0.029, 0.905],
[ 0.017, 0.900], [ 0.012, 0.895], [ 0.027, 0.893], [ 0.019, 0.886],
[ 0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879],
[-0.020, 0.954], [-0.006, 0.947], [0.003, 0.935], [0.006, 0.926],
[0.005, 0.921], [0.022, 0.923], [0.033, 0.912], [0.029, 0.905],
[0.017, 0.900], [0.012, 0.895], [0.027, 0.893], [0.019, 0.886],
[0.001, 0.883], [-0.012, 0.884], [-0.029, 0.883], [-0.038, 0.879],
[-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872],
[-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933],
[-0.077, 0.990], [-0.059, 0.993]])
x = xy[:, 0]*180/3.14159
y = xy[:, 1]*180/3.14159

triangles = np.asarray([
[67, 66, 1], [65, 2, 66], [ 1, 66, 2], [64, 2, 65], [63, 3, 64],
[60, 59, 57], [ 2, 64, 3], [ 3, 63, 4], [ 0, 67, 1], [62, 4, 63],
[57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [ 4, 62, 68],
[ 6, 5, 9], [61, 68, 62], [69, 68, 61], [ 9, 5, 70], [ 6, 8, 7],
[ 4, 70, 5], [ 8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9],
[67, 66, 1], [65, 2, 66], [1, 66, 2], [64, 2, 65], [63, 3, 64],
[60, 59, 57], [2, 64, 3], [3, 63, 4], [0, 67, 1], [62, 4, 63],
[57, 59, 56], [59, 58, 56], [61, 60, 69], [57, 69, 60], [4, 62, 68],
[6, 5, 9], [61, 68, 62], [69, 68, 61], [9, 5, 70], [6, 8, 7],
[4, 70, 5], [8, 6, 9], [56, 69, 57], [69, 56, 52], [70, 10, 9],
[54, 53, 55], [56, 55, 53], [68, 70, 4], [52, 56, 53], [11, 10, 12],
[69, 71, 68], [68, 13, 70], [10, 70, 13], [51, 50, 52], [13, 68, 71],
[52, 71, 69], [12, 10, 13], [71, 52, 50], [71, 14, 13], [50, 49, 71],
Expand Down
18 changes: 9 additions & 9 deletions examples/shapes_and_collections/artist_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ def label(xy, text):
# add a path patch
Path = mpath.Path
path_data = [
(Path.MOVETO, [0.018, -0.11]),
(Path.CURVE4, [-0.031, -0.051]),
(Path.CURVE4, [-0.115, 0.073]),
(Path.CURVE4, [-0.03 , 0.073]),
(Path.LINETO, [-0.011, 0.039]),
(Path.CURVE4, [0.043, 0.121]),
(Path.CURVE4, [0.075, -0.005]),
(Path.CURVE4, [0.035, -0.027]),
(Path.CLOSEPOLY, [0.018, -0.11])
(Path.MOVETO, [0.018, -0.110]),
(Path.CURVE4, [-0.031, -0.051]),
(Path.CURVE4, [-0.115, 0.073]),
(Path.CURVE4, [-0.030, 0.073]),
(Path.LINETO, [-0.011, 0.039]),
(Path.CURVE4, [0.043, 0.121]),
(Path.CURVE4, [0.075, -0.005]),
(Path.CURVE4, [0.035, -0.027]),
(Path.CLOSEPOLY, [0.018, -0.110])
]
codes, verts = zip(*path_data)
path = mpath.Path(verts + grid[6], codes)
Expand Down
0