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
fix all issues in the output of the pep8 unit test
  • Loading branch information
twmr committed Nov 15, 2014
commit 1e822e9dfefa6c6b136b93de5034eb30a659514d
2 changes: 1 addition & 1 deletion examples/event_handling/path_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def button_press_callback(self, event):
'whenever a mouse button is pressed'
if not self.showverts:
return
if event.inaxes == None:
if event.inaxes is None:
return
if event.button != 1:
return
Expand Down
2 changes: 1 addition & 1 deletion examples/event_handling/poly_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def button_press_callback(self, event):
'whenever a mouse button is pressed'
if not self.showverts:
return
if event.inaxes == None:
if event.inaxes is None:
return
if event.button != 1:
return
Expand Down
8 changes: 4 additions & 4 deletions examples/pylab_examples/broken_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@


# 30 points between 0 0.2] originally made using np.random.rand(30)*.2
pts = np.array([0.015, 0.166, 0.133, 0.159, 0.041, 0.024, 0.195,
0.039, 0.161, 0.018, 0.143, 0.056, 0.125, 0.096, 0.094, 0.051,
0.043, 0.021, 0.138, 0.075, 0.109, 0.195, 0.05 , 0.074, 0.079,
0.155, 0.02 , 0.01 , 0.061, 0.008])
pts = np.array([
0.015, 0.166, 0.133, 0.159, 0.041, 0.024, 0.195, 0.039, 0.161, 0.018,
0.143, 0.056, 0.125, 0.096, 0.094, 0.051, 0.043, 0.021, 0.138, 0.075,
0.109, 0.195, 0.050, 0.074, 0.079, 0.155, 0.020, 0.010, 0.061, 0.008])

# Now let's make two outlier points which are far away from everything.
pts[[3, 14]] += .8
Expand Down
1 change: 1 addition & 0 deletions examples/pylab_examples/data_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def get_daily_data():
"""
class C:
pass

def get_ticker(ticker):
vals = []

Expand Down
6 changes: 3 additions & 3 deletions examples/pylab_examples/date_demo1.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
months = MonthLocator() # every month
yearsFmt = DateFormatter('%Y')

quotes = quotes_historical_yahoo_ochl(
'INTC', date1, date2)
quotes = quotes_historical_yahoo_ochl('INTC', date1, date2)
if len(quotes) == 0:
raise SystemExit

Expand All @@ -44,7 +43,8 @@


# format the coords message box
def price(x): return '$%1.2f' % x
def price(x):
return '$%1.2f' % x
ax.fmt_xdata = DateFormatter('%Y-%m-%d')
ax.fmt_ydata = price
ax.grid(True)
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/histogram_percent_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def to_percent(y, position):
s = str(100 * y)

# The percent symbol needs escaping in latex
if matplotlib.rcParams['text.usetex'] == True:
if matplotlib.rcParams['text.usetex'] is True:
return s + r'$\%$'
else:
return s + '%'
Expand Down
5 changes: 3 additions & 2 deletions examples/pylab_examples/line_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
# See matplotlib.collections.LineCollection for more information
line_segments = LineCollection(segs,
linewidths=(0.5, 1, 1.5, 2),
colors = [colorConverter.to_rgba(i)
for i in ('b', 'g', 'r', 'c', 'm', 'y', 'k')],
colors=[colorConverter.to_rgba(i)
Copy link
Member

Choose a reason for hiding this comment

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

Not strictly a PEP8 issue, but I think this would be nicer with the colors list comprehension assigned to a variable above, and then used by name; also, I think it could use for i in 'bgrcmyk' to shorten it. (I suspect I wrote this example myself long ago...)

for i in ('b', 'g', 'r', 'c',
'm', 'y', 'k')],
linestyle = 'solid')
ax.add_collection(line_segments)
ax.set_title('Line collection with masked arrays')
Expand Down
9 changes: 5 additions & 4 deletions examples/user_interfaces/embedding_in_tk_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
import matplotlib.backends.tkagg as tkagg
from matplotlib.backends.backend_agg import FigureCanvasAgg

def draw_figure(canvas, figure, loc=[0,0]):

def draw_figure(canvas, figure, loc=[0, 0]):
Copy link
Member

Choose a reason for hiding this comment

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

sigh... mutable defaults... should remember to fix that at some point.

""" Draw a matplotlib figure onto a Tk canvas

loc: location of top-left corner of figure on canvas in pixels.

Inspired by matplotlib source: lib/matplotlib/backends/backend_tkagg.py
"""
figure_canvas_agg = FigureCanvasAgg(figure)
figure_canvas_agg.draw()
figure_x, figure_y, figure_w, figure_h = figure.bbox.bounds
figure_w, figure_h = int(figure_w), int(figure_h)
figure_w, figure_h = int(figure_w), int(figure_h)
photo = tk.PhotoImage(master=canvas, width=figure_w, height=figure_h)

# Position: convert from top-left anchor to center anchor
Expand All @@ -43,7 +44,7 @@ def draw_figure(canvas, figure, loc=[0,0]):

# Create the figure we desire to add to an existing canvas
fig = mpl.figure.Figure(figsize=(2, 1))
ax = fig.add_axes([0,0,1,1])
ax = fig.add_axes([0, 0, 1, 1])
ax.plot(X, Y)

# Keep this handle alive, or else figure will disappear
Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, on_kill=None, *args, **kw):
# Check that all things to kill are callable:
for _ in on_kill:
if not callable(_):
raise TypeError, 'on_kill must be a list of callables'
raise TypeError('on_kill must be a list of callables')
self.on_kill = on_kill
# Set up tab-completer
if has_readline:
Expand Down
8 changes: 4 additions & 4 deletions examples/user_interfaces/interactive2.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def write(self, text):

end = self.buffer.get_end_iter()

if not self.view == None:
if self.view is not None:
self.view.scroll_to_mark(self.mark, 0, True, 1, 1)

self.buffer.insert_with_tags(end, text, self.style)
Expand Down Expand Up @@ -225,7 +225,7 @@ def prompt_ps2(self):

def write_line(self, text, style=None):
start, end = self.text.get_buffer().get_bounds()
if style == None:
if style is None:
self.text.get_buffer().insert(end, text)
else:
self.text.get_buffer().insert_with_tags(end, text, style)
Expand Down Expand Up @@ -325,7 +325,7 @@ def complete_line(self):

completions = []
p = self.completer.complete(token, len(completions))
while p != None:
while p is not None:
completions.append(p)
p = self.completer.complete(token, len(completions))

Expand Down Expand Up @@ -353,7 +353,7 @@ def destroy(arg=None):
gtk.main_quit()

def key_event(widget, event):
if gtk.gdk.keyval_name( event.keyval) == 'd' and \
if gtk.gdk.keyval_name(event.keyval) == 'd' and \
event.state & gtk.gdk.CONTROL_MASK:
destroy()
return False
Expand Down
8 changes: 4 additions & 4 deletions examples/user_interfaces/mathtext_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def mathtext_to_wxbitmap(s):
############################################################

functions = [
(r'$\sin(2 \pi x)$', lambda x: sin(2*pi*x)),
(r'$\frac{4}{3}\pi x^3$', lambda x: (4.0 / 3.0) * pi * x**3),
(r'$\cos(2 \pi x)$', lambda x: cos(2*pi*x)),
(r'$\log(x)$', lambda x: log(x))
(r'$\sin(2 \pi x)$', lambda x: sin(2*pi*x)),
(r'$\frac{4}{3}\pi x^3$', lambda x: (4.0/3.0)*pi*x**3),
(r'$\cos(2 \pi x)$', lambda x: cos(2*pi*x)),
(r'$\log(x)$', lambda x: log(x))
]


Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_coding_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def test_pep8_conformance_examples():
assert_pep8_conformance(dirname=exdir,
extra_exclude_directories=blacklist,
pep8_additional_ignore=PEP8_ADDITIONAL_IGNORE +
['E501'],
['E203', 'E228', 'E261', 'E262', 'E501'],
expected_bad_files=())


Expand Down
0