Thanks to visit codestin.com
Credit goes to github.com

Skip to content

examples: fully automated fixing of E30 pep8 errors #3513

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 2 commits into from
Sep 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions examples/color/color_cycle_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@
# Tweak spacing between subplots to prevent labels from overlapping
plt.subplots_adjust(hspace=0.3)
plt.show()


1 change: 1 addition & 0 deletions examples/color/colormaps_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
gradient = np.linspace(0, 1, 256)
gradient = np.vstack((gradient, gradient))


def plot_color_gradients(cmap_category, cmap_list):
fig, axes = plt.subplots(nrows=nrows)
fig.subplots_adjust(top=0.95, bottom=0.01, left=0.2, right=0.99)
Expand Down
1 change: 1 addition & 0 deletions examples/event_handling/close_event.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import print_function
import matplotlib.pyplot as plt


def handle_close(evt):
print('Closed Figure!')

Expand Down
4 changes: 1 addition & 3 deletions examples/event_handling/data_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class PointBrowser:
generated the point will be shown in the lower axes. Use the 'n'
and 'p' keys to browse through the next and previous points
"""

def __init__(self):
self.lastind = 0

Expand All @@ -21,7 +22,6 @@ def onpress(self, event):
if event.key=='n': inc = 1
else: inc = -1


self.lastind += inc
self.lastind = np.clip(self.lastind, 0, len(xs)-1)
self.update()
Expand All @@ -37,7 +37,6 @@ def onpick(self, event):
x = event.mouseevent.xdata
y = event.mouseevent.ydata


distances = np.hypot(x-xs[event.ind], y-ys[event.ind])
indmin = distances.argmin()
dataind = event.ind[indmin]
Expand Down Expand Up @@ -80,4 +79,3 @@ def update(self):
fig.canvas.mpl_connect('key_press_event', browser.onpress)

plt.show()

6 changes: 4 additions & 2 deletions examples/event_handling/figure_axes_enter_leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@
from __future__ import print_function
import matplotlib.pyplot as plt


def enter_axes(event):
print('enter_axes', event.inaxes)
event.inaxes.patch.set_facecolor('yellow')
event.canvas.draw()


def leave_axes(event):
print('leave_axes', event.inaxes)
event.inaxes.patch.set_facecolor('white')
event.canvas.draw()


def enter_figure(event):
print('enter_figure', event.canvas.figure)
event.canvas.figure.patch.set_facecolor('red')
event.canvas.draw()


def leave_figure(event):
print('leave_figure', event.canvas.figure)
event.canvas.figure.patch.set_facecolor('grey')
Expand All @@ -42,5 +46,3 @@ def leave_figure(event):
fig2.canvas.mpl_connect('axes_leave_event', leave_axes)

plt.show()


4 changes: 2 additions & 2 deletions examples/event_handling/idle_and_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
line2, = ax.plot(y2)

N = 100


def on_idle(event):
on_idle.count +=1
print('idle', on_idle.count)
Expand All @@ -31,5 +33,3 @@ def on_idle(event):
fig.canvas.mpl_connect('idle_event', on_idle)

plt.show()


2 changes: 2 additions & 0 deletions examples/event_handling/lasso_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
from numpy import nonzero
from numpy.random import rand


class Datum(object):
colorin = colorConverter.to_rgba('red')
colorout = colorConverter.to_rgba('blue')

def __init__(self, x, y, include=False):
self.x = x
self.y = y
Expand Down
1 change: 1 addition & 0 deletions examples/event_handling/looking_glass.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
ax.plot(x, y, alpha=0.2)
line, = ax.plot(x, y, alpha=1.0, clip_path=circ)


class EventHandler:
def __init__(self):
fig.canvas.mpl_connect('button_press_event', self.onpress)
Expand Down
4 changes: 0 additions & 4 deletions examples/event_handling/path_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def __init__(self, pathpatch):
canvas.mpl_connect('motion_notify_event', self.motion_notify_callback)
self.canvas = canvas


def draw_callback(self, event):
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
self.ax.draw_artist(self.pathpatch)
Expand All @@ -74,7 +73,6 @@ def pathpatch_changed(self, pathpatch):
plt.Artist.update_from(self.line, pathpatch)
self.line.set_visible(vis) # don't use the pathpatch visibility state


def get_ind_under_point(self, event):
'get the index of the vertex under point if within epsilon tolerance'

Expand Down Expand Up @@ -138,5 +136,3 @@ def motion_notify_callback(self, event):
ax.set_ylim(-3,4)

plt.show()


5 changes: 1 addition & 4 deletions examples/event_handling/pick_event_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def pick_handler(event):
for label in ax2.get_xticklabels(): # make the xtick labels pickable
label.set_picker(True)


def onpick1(event):
if isinstance(event.artist, Line2D):
thisline = event.artist
Expand All @@ -99,8 +98,6 @@ def onpick1(event):
text = event.artist
print('onpick1 text:', text.get_text())



fig.canvas.mpl_connect('pick_event', onpick1)

if 1: # picking with a custom hit test function
Expand Down Expand Up @@ -146,6 +143,7 @@ def onpick2(event):
if 1: # picking on a scatter plot (matplotlib.collections.RegularPolyCollection)

x, y, c, s = rand(4, 100)

def onpick3(event):
ind = event.ind
print('onpick3 scatter:', ind, np.take(x, ind), np.take(y, ind))
Expand Down Expand Up @@ -174,4 +172,3 @@ def onpick4(event):


plt.show()

6 changes: 0 additions & 6 deletions examples/event_handling/pick_event_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def onpick(event):
N = len(event.ind)
if not N: return True


figi = plt.figure()
for subplotnum, dataind in enumerate(event.ind):
ax = figi.add_subplot(N,1,subplotnum+1)
Expand All @@ -37,8 +36,3 @@ def onpick(event):
fig.canvas.mpl_connect('pick_event', onpick)

plt.show()





11 changes: 9 additions & 2 deletions examples/event_handling/pipong.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

"""


class Pad(object):
def __init__(self, disp,x,y,type='l'):
self.disp = disp
Expand All @@ -46,15 +47,18 @@ def __init__(self, disp,x,y,type='l'):
else:
self.signx = 1.0
self.signy = -1.0

def contains(self, loc):
return self.disp.get_bbox().contains(loc.x,loc.y)


class Puck(object):
def __init__(self, disp, pad, field):
self.vmax= .2
self.disp = disp
self.field = field
self._reset(pad)

def _reset(self,pad):
self.x = pad.x + pad.xoffset
if pad.y < 0:
Expand All @@ -66,6 +70,7 @@ def _reset(self,pad):
self._speedlimit()
self._slower()
self._slower()

def update(self,pads):
self.x += self.vx
self.y += self.vy
Expand All @@ -91,12 +96,15 @@ def update(self,pads):
self.vy -= (randn()/300.0 + 1/300.0) * np.sign(self.vy)
self._speedlimit()
return False

def _slower(self):
self.vx /= 5.0
self.vy /= 5.0

def _faster(self):
self.vx *= 5.0
self.vy *= 5.0

def _speedlimit(self):
if self.vx > self.vmax:
self.vx = self.vmax
Expand All @@ -108,8 +116,8 @@ def _speedlimit(self):
if self.vy < -self.vmax:
self.vy = -self.vmax

class Game(object):

class Game(object):
def __init__(self, ax):
# create the initial line
self.ax = ax
Expand Down Expand Up @@ -196,7 +204,6 @@ def draw(self, evt):
puck.disp.set_offsets([puck.x,puck.y])
self.ax.draw_artist(puck.disp)


# just redraw the axes rectangle
self.canvas.blit(self.ax.bbox)

Expand Down
4 changes: 0 additions & 4 deletions examples/event_handling/poly_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def __init__(self, ax, poly):
canvas.mpl_connect('motion_notify_event', self.motion_notify_callback)
self.canvas = canvas


def draw_callback(self, event):
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
self.ax.draw_artist(self.poly)
Expand All @@ -64,7 +63,6 @@ def poly_changed(self, poly):
Artist.update_from(self.line, poly)
self.line.set_visible(vis) # don't use the poly visibility state


def get_ind_under_point(self, event):
'get the index of the vertex under point if within epsilon tolerance'

Expand Down Expand Up @@ -121,7 +119,6 @@ def key_press_callback(self, event):
self.line.set_data(zip(*self.poly.xy))
break


self.canvas.draw()

def motion_notify_callback(self, event):
Expand Down Expand Up @@ -162,4 +159,3 @@ def motion_notify_callback(self, event):
ax.set_xlim((-2,2))
ax.set_ylim((-2,2))
plt.show()

1 change: 1 addition & 0 deletions examples/event_handling/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import matplotlib.pyplot as plt
from scikits.audiolab import wavread


# A class that will downsample the data and recompute when zoomed.
class DataDisplayDownsampler(object):
def __init__(self, xdata, ydata):
Expand Down
1 change: 1 addition & 0 deletions examples/event_handling/timers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
from datetime import datetime


def update_title(axes):
axes.set_title(datetime.now())
axes.figure.canvas.draw()
Expand Down
2 changes: 2 additions & 0 deletions examples/event_handling/viewlims.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle


# We just subclass Rectangle so that it can be called with an Axes
# instance, causing the rectangle to update its shape to match the
# bounds of the Axes
Expand All @@ -12,6 +13,7 @@ def __call__(self, ax):
self.set_bounds(*ax.viewLim.bounds)
ax.figure.canvas.draw_idle()


# A class that will regenerate a fractal set as we zoom in, so that you
# can actually see the increasing detail. A box in the left panel will show
# the area to which we are zoomed.
Expand Down
2 changes: 1 addition & 1 deletion examples/event_handling/zoom_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
axsrc.scatter(x,y,s,c)
axzoom.scatter(x,y,s,c)


def onpress(event):
if event.button!=1: return
x,y = event.xdata, event.ydata
Expand All @@ -35,4 +36,3 @@ def onpress(event):

figsrc.canvas.mpl_connect('button_press_event', onpress)
show()

1 change: 0 additions & 1 deletion examples/images_contours_and_fields/image_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
plt.imshow(image)
plt.axis('off') # clear x- and y-axes
plt.show()

3 changes: 1 addition & 2 deletions examples/images_contours_and_fields/pcolormesh_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
plt.title('pcolormesh with levels')



plt.subplot(2, 1, 2)
# contours are *point* based plots, so convert our bound into point
# centers
Expand All @@ -50,4 +49,4 @@
plt.title('contourf with levels')


plt.show()
plt.show()
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@
ax2.streamplot(X, Y, U, V, density=0.6, color='k', linewidth=lw)

plt.show()

Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@
interpolation='nearest', cmap=plt.cm.gray)

plt.show()

3 changes: 1 addition & 2 deletions examples/misc/contour_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
plt.title('User-specified contours')



# Multiple filled contour lines can be specified in a single list of polygon
# vertices along with a list of vertex kinds (code types) as described in the
# Path class. This is particularly useful for polygons with holes.
Expand All @@ -47,4 +46,4 @@
plt.axis([-0.5, 3.5, -0.5, 3.5])
plt.title('User specified filled contours with holes')

plt.show()
plt.show()
2 changes: 0 additions & 2 deletions examples/misc/font_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, KERNING_UNFITTED, KERNING_UNSCALED



#fname = '/usr/share/fonts/sfd/FreeSans.ttf'
fname = matplotlib.get_data_path() + '/fonts/ttf/Vera.ttf'
font = FT2Font(fname)
Expand All @@ -23,7 +22,6 @@
# else: print '% 4d % 4d %s %s'%(glyphind, ccode, hex(int(ccode)), name)



# make a charname to charcode and glyphind dictionary
coded = {}
glyphd = {}
Expand Down
1 change: 0 additions & 1 deletion examples/misc/image_thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@
outfile = os.path.join(outdir, basename)
fig = image.thumbnail(fname, outfile, scale=0.15)
print('saved thumbnail of %s to %s'%(fname, outfile))

Loading