From 3074212423edfe4bb7c4327ebbae32d2d27a41b5 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sat, 25 Oct 2014 00:16:12 +0200 Subject: [PATCH 1/2] pep8 fix e225 Signed-off-by: Thomas Hisch --- examples/event_handling/data_browser.py | 4 ++-- examples/event_handling/idle_and_timeout.py | 4 ++-- examples/event_handling/keypress_demo.py | 2 +- examples/event_handling/looking_glass.py | 4 ++-- examples/event_handling/path_editor.py | 6 ++--- examples/event_handling/pick_event_demo2.py | 2 +- examples/event_handling/pipong.py | 24 +++++++++---------- examples/event_handling/poly_editor.py | 14 +++++------ examples/event_handling/zoom_window.py | 2 +- examples/misc/image_thumbnail.py | 2 +- examples/misc/rc_traits.py | 6 ++--- examples/misc/svg_filter_pie.py | 2 +- examples/pylab_examples/animation_demo.py | 2 +- examples/pylab_examples/arrow_demo.py | 12 +++++----- examples/pylab_examples/axes_zoom_effect.py | 12 +++++----- examples/pylab_examples/barcode_demo.py | 2 +- examples/pylab_examples/boxplot_demo.py | 6 ++--- examples/pylab_examples/clippedline.py | 2 +- examples/pylab_examples/color_by_yvalue.py | 2 +- examples/pylab_examples/contour_label_demo.py | 2 +- examples/pylab_examples/contourf_log.py | 2 +- examples/pylab_examples/coords_demo.py | 2 +- .../pylab_examples/date_index_formatter.py | 2 +- examples/pylab_examples/demo_agg_filter.py | 14 +++++------ examples/pylab_examples/fancyarrow_demo.py | 2 +- examples/pylab_examples/fill_between_demo.py | 12 +++++----- examples/pylab_examples/fill_betweenx_demo.py | 8 +++---- examples/pylab_examples/fill_spiral.py | 6 ++--- examples/pylab_examples/finance_work2.py | 16 ++++++------- examples/pylab_examples/fonts_demo.py | 2 +- examples/pylab_examples/fonts_demo_kw.py | 2 +- examples/pylab_examples/hexbin_demo2.py | 2 +- examples/pylab_examples/image_nonuniform.py | 2 +- .../pylab_examples/image_slices_viewer.py | 2 +- examples/pylab_examples/layer_images.py | 2 +- examples/pylab_examples/manual_axis.py | 4 ++-- examples/pylab_examples/multi_image.py | 2 +- .../pylab_examples/newscalarformatter_demo.py | 16 ++++++------- examples/pylab_examples/pie_demo2.py | 2 +- .../pylab_examples/scatter_custom_symbol.py | 2 +- examples/pylab_examples/specgram_demo.py | 2 +- examples/pylab_examples/step_demo.py | 2 +- examples/pylab_examples/tex_unicode_demo.py | 4 ++-- .../pylab_examples/usetex_baseline_test.py | 4 ++-- examples/pylab_examples/zorder_demo.py | 2 +- .../specialty_plots/advanced_hillshading.py | 2 +- examples/units/bar_demo2.py | 6 ++--- examples/units/basic_units.py | 4 ++-- examples/units/evans_test.py | 2 +- examples/units/units_sample.py | 2 +- examples/user_interfaces/gtk_spreadsheet.py | 2 +- examples/user_interfaces/interactive.py | 6 ++--- examples/user_interfaces/interactive2.py | 4 ++-- examples/user_interfaces/pylab_with_gtk.py | 2 +- examples/user_interfaces/wxcursor_demo.py | 4 ++-- examples/widgets/menu.py | 2 +- 56 files changed, 132 insertions(+), 132 deletions(-) diff --git a/examples/event_handling/data_browser.py b/examples/event_handling/data_browser.py index dd2d5948d6d3..6ba652d88f4b 100644 --- a/examples/event_handling/data_browser.py +++ b/examples/event_handling/data_browser.py @@ -19,7 +19,7 @@ def __init__(self): def onpress(self, event): if self.lastind is None: return if event.key not in ('n', 'p'): return - if event.key=='n': inc = 1 + if event.key == 'n': inc = 1 else: inc = -1 self.lastind += inc @@ -28,7 +28,7 @@ def onpress(self, event): def onpick(self, event): - if event.artist!=line: return True + if event.artist != line: return True N = len(event.ind) if not N: return True diff --git a/examples/event_handling/idle_and_timeout.py b/examples/event_handling/idle_and_timeout.py index 184f0eb53d84..5495e8b26443 100644 --- a/examples/event_handling/idle_and_timeout.py +++ b/examples/event_handling/idle_and_timeout.py @@ -19,12 +19,12 @@ def on_idle(event): - on_idle.count +=1 + on_idle.count += 1 print('idle', on_idle.count) line1.set_ydata(np.sin(2*np.pi*t*(N-on_idle.count)/float(N))) event.canvas.draw() # test boolean return removal - if on_idle.count==N: + if on_idle.count == N: return False return True on_idle.cid = None diff --git a/examples/event_handling/keypress_demo.py b/examples/event_handling/keypress_demo.py index d814c8ce334b..0cf66313fb16 100755 --- a/examples/event_handling/keypress_demo.py +++ b/examples/event_handling/keypress_demo.py @@ -12,7 +12,7 @@ def press(event): print('press', event.key) sys.stdout.flush() - if event.key=='x': + if event.key == 'x': visible = xl.get_visible() xl.set_visible(not visible) fig.canvas.draw() diff --git a/examples/event_handling/looking_glass.py b/examples/event_handling/looking_glass.py index a707bc13d364..b981a4ec7ff1 100644 --- a/examples/event_handling/looking_glass.py +++ b/examples/event_handling/looking_glass.py @@ -21,7 +21,7 @@ def __init__(self): self.pressevent = None def onpress(self, event): - if event.inaxes!=ax: + if event.inaxes != ax: return if not circ.contains(event)[0]: @@ -34,7 +34,7 @@ def onrelease(self, event): self.x0, self.y0 = circ.center def onmove(self, event): - if self.pressevent is None or event.inaxes!=self.pressevent.inaxes: + if self.pressevent is None or event.inaxes != self.pressevent.inaxes: return dx = event.xdata - self.pressevent.xdata diff --git a/examples/event_handling/path_editor.py b/examples/event_handling/path_editor.py index 108592b2c16d..2a4a0462a5e1 100644 --- a/examples/event_handling/path_editor.py +++ b/examples/event_handling/path_editor.py @@ -83,7 +83,7 @@ def get_ind_under_point(self, event): d = np.sqrt((xt-event.x)**2 + (yt-event.y)**2) ind = d.argmin() - if d[ind]>=self.epsilon: + if d[ind] >= self.epsilon: ind = None return ind @@ -91,7 +91,7 @@ def get_ind_under_point(self, event): def button_press_callback(self, event): 'whenever a mouse button is pressed' if not self.showverts: return - if event.inaxes==None: return + if event.inaxes == None: return if event.button != 1: return self._ind = self.get_ind_under_point(event) @@ -104,7 +104,7 @@ def button_release_callback(self, event): def key_press_callback(self, event): 'whenever a key is pressed' if not event.inaxes: return - if event.key=='t': + if event.key == 't': self.showverts = not self.showverts self.line.set_visible(self.showverts) if not self.showverts: self._ind = None diff --git a/examples/event_handling/pick_event_demo2.py b/examples/event_handling/pick_event_demo2.py index 991b41999807..2ef8c75131dd 100644 --- a/examples/event_handling/pick_event_demo2.py +++ b/examples/event_handling/pick_event_demo2.py @@ -18,7 +18,7 @@ def onpick(event): - if event.artist!=line: return True + if event.artist != line: return True N = len(event.ind) if not N: return True diff --git a/examples/event_handling/pipong.py b/examples/event_handling/pipong.py index 771efa7af89a..4a403b5e7e5d 100755 --- a/examples/event_handling/pipong.py +++ b/examples/event_handling/pipong.py @@ -38,10 +38,10 @@ def __init__(self, disp, x, y, type='l'): self.score = 0 self.xoffset = 0.3 self.yoffset = 0.1 - if type=='r': + if type == 'r': self.xoffset *= -1.0 - if type=='l' or type=='r': + if type == 'l' or type == 'r': self.signx = -1.0 self.signy = 1.0 else: @@ -54,7 +54,7 @@ def contains(self, loc): class Puck(object): def __init__(self, disp, pad, field): - self.vmax= .2 + self.vmax = .2 self.disp = disp self.field = field self._reset(pad) @@ -76,8 +76,8 @@ def update(self, pads): self.y += self.vy for pad in pads: if pad.contains(self): - self.vx *= 1.2 *pad.signx - self.vy *= 1.2 *pad.signy + self.vx *= 1.2 * pad.signx + self.vy *= 1.2 * pad.signy fudge = .001 # probably cleaner with something like...if not self.field.contains(self.x, self.y): if self.x < 0+fudge: @@ -121,9 +121,9 @@ class Game(object): def __init__(self, ax): # create the initial line self.ax = ax - padAx = padBx= .50 - padAy = padBy= .30 - padBx+=6.3 + padAx = padBx = .50 + padAy = padBy = .30 + padBx += 6.3 pA, = self.ax.barh(padAy, .2, height=.3, color='k', alpha=.5, edgecolor='b', lw=2, label="Player B", animated=True) pB, = self.ax.barh(padBy, .2, height=.3, left=padBx, color='k', alpha=.5, edgecolor='r', lw=2, label="Player A", animated=True) @@ -147,7 +147,7 @@ def __init__(self, ax): self.pads = [] self.pads.append(Pad(pA, 0, padAy)) self.pads.append(Pad(pB, padBx, padBy, 'r')) - self.pucks =[] + self.pucks = [] self.i = self.ax.annotate(instructions, (.5, 0.5), name='monospace', verticalalignment='center', @@ -190,8 +190,8 @@ def draw(self, evt): for puck in self.pucks: if puck.update(self.pads): # we only get here if someone scored - self.pads[0].disp.set_label(" "+ str(self.pads[0].score)) - self.pads[1].disp.set_label(" "+ str(self.pads[1].score)) + self.pads[0].disp.set_label(" " + str(self.pads[0].score)) + self.pads[1].disp.set_label(" " + str(self.pads[1].score)) self.ax.legend(loc='center') self.leg = self.ax.get_legend() #self.leg.draw_frame(False) #don't draw the legend border @@ -207,7 +207,7 @@ def draw(self, evt): # just redraw the axes rectangle self.canvas.blit(self.ax.bbox) - if self.cnt==50000: + if self.cnt == 50000: # just so we don't get carried away print("...and you've been playing for too long!!!") plt.close() diff --git a/examples/event_handling/poly_editor.py b/examples/event_handling/poly_editor.py index 380cf3f7b1ef..32061c74f5e8 100644 --- a/examples/event_handling/poly_editor.py +++ b/examples/event_handling/poly_editor.py @@ -74,7 +74,7 @@ def get_ind_under_point(self, event): indseq = np.nonzero(np.equal(d, np.amin(d)))[0] ind = indseq[0] - if d[ind]>=self.epsilon: + if d[ind] >= self.epsilon: ind = None return ind @@ -82,7 +82,7 @@ def get_ind_under_point(self, event): def button_press_callback(self, event): 'whenever a mouse button is pressed' if not self.showverts: return - if event.inaxes==None: return + if event.inaxes == None: return if event.button != 1: return self._ind = self.get_ind_under_point(event) @@ -95,23 +95,23 @@ def button_release_callback(self, event): def key_press_callback(self, event): 'whenever a key is pressed' if not event.inaxes: return - if event.key=='t': + if event.key == 't': self.showverts = not self.showverts self.line.set_visible(self.showverts) if not self.showverts: self._ind = None - elif event.key=='d': + elif event.key == 'd': ind = self.get_ind_under_point(event) if ind is not None: - self.poly.xy = [tup for i, tup in enumerate(self.poly.xy) if i!=ind] + self.poly.xy = [tup for i, tup in enumerate(self.poly.xy) if i != ind] self.line.set_data(zip(*self.poly.xy)) - elif event.key=='i': + elif event.key == 'i': xys = self.poly.get_transform().transform(self.poly.xy) p = event.x, event.y # display coords for i in range(len(xys)-1): s0 = xys[i] s1 = xys[i+1] d = dist_point_to_segment(p, s0, s1) - if d<=self.epsilon: + if d <= self.epsilon: self.poly.xy = np.array( list(self.poly.xy[:i]) + [(event.xdata, event.ydata)] + diff --git a/examples/event_handling/zoom_window.py b/examples/event_handling/zoom_window.py index 985df5d28ec0..427a858c77a6 100644 --- a/examples/event_handling/zoom_window.py +++ b/examples/event_handling/zoom_window.py @@ -28,7 +28,7 @@ def onpress(event): - if event.button!=1: return + if event.button != 1: return x, y = event.xdata, event.ydata axzoom.set_xlim(x-0.1, x+0.1) axzoom.set_ylim(y-0.1, y+0.1) diff --git a/examples/misc/image_thumbnail.py b/examples/misc/image_thumbnail.py index 3d5be8f7eef0..aee300426fd9 100644 --- a/examples/misc/image_thumbnail.py +++ b/examples/misc/image_thumbnail.py @@ -10,7 +10,7 @@ import matplotlib.image as image -if len(sys.argv)!=2: +if len(sys.argv) != 2: print('Usage: python %s IMAGEDIR'%__file__) raise SystemExit indir = sys.argv[1] diff --git a/examples/misc/rc_traits.py b/examples/misc/rc_traits.py index da41188dd114..b329ec9ce924 100644 --- a/examples/misc/rc_traits.py +++ b/examples/misc/rc_traits.py @@ -52,16 +52,16 @@ def __init__(self, r=0., g=0., b=0., a=1.): self.a = a def __repr__(self): - return 'r,g,b,a = (%1.2f, %1.2f, %1.2f, %1.2f)'%\ + return 'r,g,b,a = (%1.2f, %1.2f, %1.2f, %1.2f)' %\ (self.r, self.g, self.b, self.a) def tuple_to_rgba(ob, name, val): tup = [float(x) for x in val] - if len(tup)==3: + if len(tup) == 3: r, g, b = tup return RGBA(r, g, b) - elif len(tup)==4: + elif len(tup) == 4: r, g, b, a = tup return RGBA(r, g, b, a) else: diff --git a/examples/misc/svg_filter_pie.py b/examples/misc/svg_filter_pie.py index 2bd2e34d7993..924807c060f5 100644 --- a/examples/misc/svg_filter_pie.py +++ b/examples/misc/svg_filter_pie.py @@ -20,7 +20,7 @@ labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' fracs = [15, 30, 45, 10] -explode=(0, 0.05, 0, 0) +explode = (0, 0.05, 0, 0) # We want to draw the shadow for each pie but we will not use "shadow" # option as it does'n save the references to the shadow patches. diff --git a/examples/pylab_examples/animation_demo.py b/examples/pylab_examples/animation_demo.py index 15cab364683d..f294a189f75f 100644 --- a/examples/pylab_examples/animation_demo.py +++ b/examples/pylab_examples/animation_demo.py @@ -14,7 +14,7 @@ z = x * y[:, np.newaxis] for i in xrange(5): - if i==0: + if i == 0: p = plt.imshow(z) fig = plt.gcf() plt.clim() # clamp the color limits diff --git a/examples/pylab_examples/arrow_demo.py b/examples/pylab_examples/arrow_demo.py index 6931477056d6..7875247a9a0a 100644 --- a/examples/pylab_examples/arrow_demo.py +++ b/examples/pylab_examples/arrow_demo.py @@ -11,7 +11,7 @@ """ from pylab import * -rates_to_bases={'r1': 'AT', 'r2': 'TA', 'r3': 'GA', 'r4': 'AG', 'r5': 'CA', 'r6': 'AC', \ +rates_to_bases = {'r1': 'AT', 'r2': 'TA', 'r3': 'GA', 'r4': 'AG', 'r5': 'CA', 'r6': 'AC', \ 'r7': 'GT', 'r8': 'TG', 'r9': 'CT', 'r10': 'TC', 'r11': 'GC', 'r12': 'CG'} numbered_bases_to_rates = dict([(v, k) for k, v in rates_to_bases.items()]) lettered_bases_to_rates = dict([(v, 'r'+v) for k, v in rates_to_bases.items()]) @@ -53,7 +53,7 @@ def make_arrow_plot(data, size=4, display='length', shape='right', \ max_text_size = size*12 min_text_size = size label_text_size = size*2.5 - text_params={'ha': 'center', 'va': 'center', 'family': 'sans-serif',\ + text_params = {'ha': 'center', 'va': 'center', 'family': 'sans-serif',\ 'fontweight': 'bold'} r2 = sqrt(2) @@ -117,7 +117,7 @@ def do_fontsize(k): max_arrow_width = max_arrow_width max_head_width = 2.5*max_arrow_width max_head_length = 2*max_arrow_width - arrow_params={'length_includes_head': True, 'shape': shape, \ + arrow_params = {'length_includes_head': True, 'shape': shape, \ 'head_starts_at_zero': head_starts_at_zero} ax = gca() sf = 0.6 # max arrow size represents this in data coords @@ -154,7 +154,7 @@ def do_fontsize(k): def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): # set the length of the arrow if display == 'length': - length = max_head_length+(max_arrow_length-max_head_length)*\ + length = max_head_length+(max_arrow_length-max_head_length) *\ data[pair]/sf else: length = max_arrow_length @@ -162,7 +162,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): if display == 'alph': alpha = min(data[pair]/sf, alpha) else: - alpha=alpha + alpha = alpha # set the width of the arrow if display == 'width': scale = data[pair]/sf @@ -295,7 +295,7 @@ def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor): scaled = True if d is None: d = all_on_max - scaled=False + scaled = False if len(argv) > 2: display = argv[2] else: diff --git a/examples/pylab_examples/axes_zoom_effect.py b/examples/pylab_examples/axes_zoom_effect.py index 11e77cbf7189..5953c14f2de5 100644 --- a/examples/pylab_examples/axes_zoom_effect.py +++ b/examples/pylab_examples/axes_zoom_effect.py @@ -49,9 +49,9 @@ def zoom_effect01(ax1, ax2, xmin, xmax, **kwargs): mybbox1 = TransformedBbox(bbox, trans1) mybbox2 = TransformedBbox(bbox, trans2) - prop_patches=kwargs.copy() - prop_patches["ec"]="none" - prop_patches["alpha"]=0.2 + prop_patches = kwargs.copy() + prop_patches["ec"] = "none" + prop_patches["alpha"] = 0.2 c1, c2, bbox_patch1, bbox_patch2, p = \ connect_bbox(mybbox1, mybbox2, @@ -82,9 +82,9 @@ def zoom_effect02(ax1, ax2, **kwargs): mybbox1 = ax1.bbox mybbox2 = TransformedBbox(ax1.viewLim, trans) - prop_patches=kwargs.copy() - prop_patches["ec"]="none" - prop_patches["alpha"]=0.2 + prop_patches = kwargs.copy() + prop_patches["ec"] = "none" + prop_patches["alpha"] = 0.2 c1, c2, bbox_patch1, bbox_patch2, p = \ connect_bbox(mybbox1, mybbox2, diff --git a/examples/pylab_examples/barcode_demo.py b/examples/pylab_examples/barcode_demo.py index 2d31af2421e2..5178a9fc2683 100644 --- a/examples/pylab_examples/barcode_demo.py +++ b/examples/pylab_examples/barcode_demo.py @@ -3,7 +3,7 @@ from numpy.random import rand # the bar -x = where(rand(500)>0.7, 1.0, 0.0) +x = where(rand(500) > 0.7, 1.0, 0.0) axprops = dict(xticks=[], yticks=[]) barprops = dict(aspect='auto', cmap=cm.binary, interpolation='nearest') diff --git a/examples/pylab_examples/boxplot_demo.py b/examples/pylab_examples/boxplot_demo.py index e6fbfbacb275..4dd53cd3487d 100644 --- a/examples/pylab_examples/boxplot_demo.py +++ b/examples/pylab_examples/boxplot_demo.py @@ -7,11 +7,11 @@ from pylab import * # fake up some data -spread= rand(50) * 100 +spread = rand(50) * 100 center = ones(25) * 50 flier_high = rand(10) * 100 + 100 flier_low = rand(10) * -100 -data =concatenate((spread, center, flier_high, flier_low), 0) +data = concatenate((spread, center, flier_high, flier_low), 0) # basic plot boxplot(data) @@ -37,7 +37,7 @@ boxplot(data, 0, 'rs', 0, 0.75) # fake up some more data -spread= rand(50) * 100 +spread = rand(50) * 100 center = ones(25) * 40 flier_high = rand(10) * 100 + 100 flier_low = rand(10) * -100 diff --git a/examples/pylab_examples/clippedline.py b/examples/pylab_examples/clippedline.py index 0d9e313f8997..d33bf4b2a1e4 100644 --- a/examples/pylab_examples/clippedline.py +++ b/examples/pylab_examples/clippedline.py @@ -35,7 +35,7 @@ def draw(self, renderer): self._x = self.xorig[ind0:ind1] self._y = self.yorig[ind0:ind1] N = len(self._x) - if N<1000: + if N < 1000: self._marker = 's' self._linestyle = '-' else: diff --git a/examples/pylab_examples/color_by_yvalue.py b/examples/pylab_examples/color_by_yvalue.py index 689352b6c5e8..f622a50e21b8 100644 --- a/examples/pylab_examples/color_by_yvalue.py +++ b/examples/pylab_examples/color_by_yvalue.py @@ -12,7 +12,7 @@ supper = ma.masked_where(s < upper, s) slower = ma.masked_where(s > lower, s) -smiddle = ma.masked_where(logical_or(supper), s) +smiddle = ma.masked_where(logical_or(s < lower, s > upper), s) plot(t, slower, 'r', t, smiddle, 'b', t, supper, 'g') show() diff --git a/examples/pylab_examples/contour_label_demo.py b/examples/pylab_examples/contour_label_demo.py index 763f5ec25e0a..42eb8f579406 100644 --- a/examples/pylab_examples/contour_label_demo.py +++ b/examples/pylab_examples/contour_label_demo.py @@ -42,7 +42,7 @@ class nf(float): def __repr__(self): str = '%.1f' % (self.__float__(),) - if str[-1]=='0': + if str[-1] == '0': return '%.0f' % self.__float__() else: return '%.1f' % self.__float__() diff --git a/examples/pylab_examples/contourf_log.py b/examples/pylab_examples/contourf_log.py index 60a6f14e8ede..a10879526a67 100644 --- a/examples/pylab_examples/contourf_log.py +++ b/examples/pylab_examples/contourf_log.py @@ -25,7 +25,7 @@ # The following is not strictly essential, but it will eliminate # a warning. Comment it out to see the warning. -z = ma.masked_where(z<= 0, z) +z = ma.masked_where(z <= 0, z) # Automatic selection of levels works; setting the diff --git a/examples/pylab_examples/coords_demo.py b/examples/pylab_examples/coords_demo.py index 3d0e5158321a..800674417174 100755 --- a/examples/pylab_examples/coords_demo.py +++ b/examples/pylab_examples/coords_demo.py @@ -26,7 +26,7 @@ def on_move(event): def on_click(event): # get the x and y coords, flip y from top to bottom x, y = event.x, event.y - if event.button==1: + if event.button == 1: if event.inaxes is not None: print('data coords %f %f' % (event.xdata, event.ydata)) diff --git a/examples/pylab_examples/date_index_formatter.py b/examples/pylab_examples/date_index_formatter.py index 16871cb36e92..9e846048276c 100644 --- a/examples/pylab_examples/date_index_formatter.py +++ b/examples/pylab_examples/date_index_formatter.py @@ -28,7 +28,7 @@ def __init__(self, dates, fmt='%Y-%m-%d'): def __call__(self, x, pos=0): 'Return the label for time x at position pos' ind = int(round(x)) - if ind>=len(self.dates) or ind<0: return '' + if ind >= len(self.dates) or ind < 0: return '' return self.dates[ind].strftime(self.fmt) diff --git a/examples/pylab_examples/demo_agg_filter.py b/examples/pylab_examples/demo_agg_filter.py index 6e62da100316..c033328e5159 100644 --- a/examples/pylab_examples/demo_agg_filter.py +++ b/examples/pylab_examples/demo_agg_filter.py @@ -8,9 +8,9 @@ def smooth1d(x, window_len): # copied from http://www.scipy.org/Cookbook/SignalSmooth - s=np.r_[2*x[0]-x[window_len:1:-1], x, 2*x[-1]-x[-1:-window_len:-1]] + s = np.r_[2*x[0]-x[window_len:1:-1], x, 2*x[-1]-x[-1:-window_len:-1]] w = np.hanning(window_len) - y=np.convolve(w/w.sum(), s, mode='same') + y = np.convolve(w/w.sum(), s, mode='same') return y[window_len-1:-window_len+1] @@ -68,9 +68,9 @@ def __init__(self, sigma, alpha=0.5, color=None): self.sigma = sigma self.alpha = alpha if color is None: - self.color=(0, 0, 0) + self.color = (0, 0, 0) else: - self.color=color + self.color = color def get_pad(self, dpi): return int(self.sigma*3/72.*dpi) @@ -135,9 +135,9 @@ class GrowFilter(BaseFilter): def __init__(self, pixels, color=None): self.pixels = pixels if color is None: - self.color=(1, 1, 1) + self.color = (1, 1, 1) else: - self.color=color + self.color = color def __call__(self, im, dpi): pad = self.pixels @@ -292,7 +292,7 @@ def drop_shadow_patches(ax): def light_filter_pie(ax): fracs = [15, 30, 45, 10] - explode=(0, 0.05, 0, 0) + explode = (0, 0.05, 0, 0) pies = ax.pie(fracs, explode=explode) ax.patch.set_visible(True) diff --git a/examples/pylab_examples/fancyarrow_demo.py b/examples/pylab_examples/fancyarrow_demo.py index 8e4be72efe78..6d9b527be93e 100644 --- a/examples/pylab_examples/fancyarrow_demo.py +++ b/examples/pylab_examples/fancyarrow_demo.py @@ -3,7 +3,7 @@ styles = mpatches.ArrowStyle.get_styles() -ncol=2 +ncol = 2 nrow = (len(styles)+1) // ncol figheight = (nrow+0.5) fig1 = plt.figure(1, (4.*ncol/1.5, figheight/1.5)) diff --git a/examples/pylab_examples/fill_between_demo.py b/examples/pylab_examples/fill_between_demo.py index d764dcba55e8..df0f0c2894ad 100644 --- a/examples/pylab_examples/fill_between_demo.py +++ b/examples/pylab_examples/fill_between_demo.py @@ -24,15 +24,15 @@ # because of edge effects over multiple contiguous regions. fig, (ax, ax1) = plt.subplots(2, 1, sharex=True) ax.plot(x, y1, x, y2, color='black') -ax.fill_between(x, y1, y2, where=y2>=y1, facecolor='green', interpolate=True) -ax.fill_between(x, y1, y2, where=y2<=y1, facecolor='red', interpolate=True) +ax.fill_between(x, y1, y2, where=y2 >= y1, facecolor='green', interpolate=True) +ax.fill_between(x, y1, y2, where=y2 <= y1, facecolor='red', interpolate=True) ax.set_title('fill between where') # Test support for masked arrays. y2 = np.ma.masked_greater(y2, 1.0) ax1.plot(x, y1, x, y2, color='black') -ax1.fill_between(x, y1, y2, where=y2>=y1, facecolor='green', interpolate=True) -ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red', interpolate=True) +ax1.fill_between(x, y1, y2, where=y2 >= y1, facecolor='green', interpolate=True) +ax1.fill_between(x, y1, y2, where=y2 <= y1, facecolor='red', interpolate=True) ax1.set_title('Now regions with y2>1 are masked') # This example illustrates a problem; because of the data @@ -51,8 +51,8 @@ theta = 0.9 ax.axhline(theta, color='green', lw=2, alpha=0.5) ax.axhline(-theta, color='red', lw=2, alpha=0.5) -ax.fill_between(x, 0, 1, where=y>theta, facecolor='green', alpha=0.5, transform=trans) -ax.fill_between(x, 0, 1, where=y<-theta, facecolor='red', alpha=0.5, transform=trans) +ax.fill_between(x, 0, 1, where=y > theta, facecolor='green', alpha=0.5, transform=trans) +ax.fill_between(x, 0, 1, where=y < -theta, facecolor='red', alpha=0.5, transform=trans) plt.show() diff --git a/examples/pylab_examples/fill_betweenx_demo.py b/examples/pylab_examples/fill_betweenx_demo.py index 1bd48db40df2..708f81903cf0 100644 --- a/examples/pylab_examples/fill_betweenx_demo.py +++ b/examples/pylab_examples/fill_betweenx_demo.py @@ -32,16 +32,16 @@ fig = figure() ax = fig.add_subplot(211) ax.plot(y1, x, y2, x, color='black') -ax.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green') -ax.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red') +ax.fill_betweenx(x, y1, y2, where=y2 >= y1, facecolor='green') +ax.fill_betweenx(x, y1, y2, where=y2 <= y1, facecolor='red') ax.set_title('fill between where') # Test support for masked arrays. y2 = np.ma.masked_greater(y2, 1.0) ax1 = fig.add_subplot(212, sharex=ax) ax1.plot(y1, x, y2, x, color='black') -ax1.fill_betweenx(x, y1, y2, where=y2>=y1, facecolor='green') -ax1.fill_betweenx(x, y1, y2, where=y2<=y1, facecolor='red') +ax1.fill_betweenx(x, y1, y2, where=y2 >= y1, facecolor='green') +ax1.fill_betweenx(x, y1, y2, where=y2 <= y1, facecolor='red') ax1.set_title('Now regions with y2 > 1 are masked') # This example illustrates a problem; because of the data diff --git a/examples/pylab_examples/fill_spiral.py b/examples/pylab_examples/fill_spiral.py index 787e1755bdc8..cd5739b93506 100644 --- a/examples/pylab_examples/fill_spiral.py +++ b/examples/pylab_examples/fill_spiral.py @@ -3,8 +3,8 @@ from pylab import * theta = arange(0, 8*pi, 0.1) -a=1 -b=.2 +a = 1 +b = .2 for dt in arange(0, 2*pi, pi/2.0): @@ -19,6 +19,6 @@ xf = concatenate((x, x2[::-1])) yf = concatenate((y, y2[::-1])) - p1=fill(xf, yf) + p1 = fill(xf, yf) show() diff --git a/examples/pylab_examples/finance_work2.py b/examples/pylab_examples/finance_work2.py index cd341db1bac9..13eca5e87648 100644 --- a/examples/pylab_examples/finance_work2.py +++ b/examples/pylab_examples/finance_work2.py @@ -29,7 +29,7 @@ def moving_average(x, n, type='simple'): """ x = np.asarray(x) - if type=='simple': + if type == 'simple': weights = np.ones(n) else: weights = np.exp(np.linspace(-1., 0., n)) @@ -50,8 +50,8 @@ def relative_strength(prices, n=14): deltas = np.diff(prices) seed = deltas[:n+1] - up = seed[seed>=0].sum()/n - down = -seed[seed<0].sum()/n + up = seed[seed >= 0].sum()/n + down = -seed[seed < 0].sum()/n rs = up/down rsi = np.zeros_like(prices) rsi[:n] = 100. - 100./(1.+rs) @@ -59,7 +59,7 @@ def relative_strength(prices, n=14): for i in range(n, len(prices)): delta = deltas[i-1] # cause the diff is 1 shorter - if delta>0: + if delta > 0: upval = delta downval = 0. else: @@ -112,8 +112,8 @@ def moving_average_convergence(x, nslow=26, nfast=12): ax1.plot(r.date, rsi, color=fillcolor) ax1.axhline(70, color=fillcolor) ax1.axhline(30, color=fillcolor) -ax1.fill_between(r.date, rsi, 70, where=(rsi>=70), facecolor=fillcolor, edgecolor=fillcolor) -ax1.fill_between(r.date, rsi, 30, where=(rsi<=30), facecolor=fillcolor, edgecolor=fillcolor) +ax1.fill_between(r.date, rsi, 70, where=(rsi >= 70), facecolor=fillcolor, edgecolor=fillcolor) +ax1.fill_between(r.date, rsi, 30, where=(rsi <= 30), facecolor=fillcolor, edgecolor=fillcolor) ax1.text(0.6, 0.9, '>70 = overbought', va='top', transform=ax1.transAxes, fontsize=textsize) ax1.text(0.6, 0.1, '<30 = oversold', transform=ax1.transAxes, fontsize=textsize) ax1.set_ylim(0, 100) @@ -128,7 +128,7 @@ def moving_average_convergence(x, nslow=26, nfast=12): deltas = np.zeros_like(prices) deltas[1:] = np.diff(prices) -up = deltas>0 +up = deltas > 0 ax2.vlines(r.date[up], low[up], high[up], color='black', label='_nolegend_') ax2.vlines(r.date[~up], low[~up], high[~up], color='black', label='_nolegend_') ma20 = moving_average(prices, 20, type='simple') @@ -177,7 +177,7 @@ def moving_average_convergence(x, nslow=26, nfast=12): #ax3.set_yticks([]) # turn off upper axis tick labels, rotate the lower ones, etc for ax in ax1, ax2, ax2t, ax3: - if ax!=ax3: + if ax != ax3: for label in ax.get_xticklabels(): label.set_visible(False) else: diff --git a/examples/pylab_examples/fonts_demo.py b/examples/pylab_examples/fonts_demo.py index 9ee520fb76a1..002eed72b850 100644 --- a/examples/pylab_examples/fonts_demo.py +++ b/examples/pylab_examples/fonts_demo.py @@ -48,7 +48,7 @@ # Show variant options -variant= ['normal', 'small-caps'] +variant = ['normal', 'small-caps'] t = text(0.0, 0.9, 'variant', fontproperties=font1, **alignment) diff --git a/examples/pylab_examples/fonts_demo_kw.py b/examples/pylab_examples/fonts_demo_kw.py index 570646bbafb5..eaab06d50e1b 100644 --- a/examples/pylab_examples/fonts_demo_kw.py +++ b/examples/pylab_examples/fonts_demo_kw.py @@ -37,7 +37,7 @@ # Show variant options -variant= ['normal', 'small-caps'] +variant = ['normal', 'small-caps'] t = text(0.0, 0.9, 'variant', **alignment) diff --git a/examples/pylab_examples/hexbin_demo2.py b/examples/pylab_examples/hexbin_demo2.py index 392362489668..6d8f74752c92 100644 --- a/examples/pylab_examples/hexbin_demo2.py +++ b/examples/pylab_examples/hexbin_demo2.py @@ -36,7 +36,7 @@ ymin = y.min() ymax = y.max() -gridsize=30 +gridsize = 30 plt.subplot(211) plt.hexbin(x, y, C=z, gridsize=gridsize, marginals=True, cmap=plt.cm.RdBu, diff --git a/examples/pylab_examples/image_nonuniform.py b/examples/pylab_examples/image_nonuniform.py index cbadce80f6c7..c488504c86c7 100644 --- a/examples/pylab_examples/image_nonuniform.py +++ b/examples/pylab_examples/image_nonuniform.py @@ -9,7 +9,7 @@ from matplotlib.image import NonUniformImage from matplotlib import cm -interp='nearest' +interp = 'nearest' x = np.linspace(-4, 4, 9) x2 = x**3 diff --git a/examples/pylab_examples/image_slices_viewer.py b/examples/pylab_examples/image_slices_viewer.py index 488952106f54..dd4cccb398cd 100644 --- a/examples/pylab_examples/image_slices_viewer.py +++ b/examples/pylab_examples/image_slices_viewer.py @@ -17,7 +17,7 @@ def __init__(self, ax, X): def onscroll(self, event): print("%s %s" % (event.button, event.step)) - if event.button=='up': + if event.button == 'up': self.ind = numpy.clip(self.ind+1, 0, self.slices-1) else: self.ind = numpy.clip(self.ind-1, 0, self.slices-1) diff --git a/examples/pylab_examples/layer_images.py b/examples/pylab_examples/layer_images.py index b46473cbb119..b1ee9469c11b 100644 --- a/examples/pylab_examples/layer_images.py +++ b/examples/pylab_examples/layer_images.py @@ -7,7 +7,7 @@ def func3(x, y): - return (1- x/2 + x**5 + y**3)*exp(-x**2-y**2) + return (1 - x/2 + x**5 + y**3)*exp(-x**2-y**2) # make these smaller to increase the resolution dx, dy = 0.05, 0.05 diff --git a/examples/pylab_examples/manual_axis.py b/examples/pylab_examples/manual_axis.py index 8f638bc9c1ec..5c993f45fb5a 100644 --- a/examples/pylab_examples/manual_axis.py +++ b/examples/pylab_examples/manual_axis.py @@ -16,7 +16,7 @@ def make_xaxis(ax, yloc, offset=0.05, **props): xmin, xmax = ax.get_xlim() locs = [loc for loc in ax.xaxis.get_majorticklocs() - if loc>=xmin and loc<=xmax] + if loc >= xmin and loc <= xmax] tickline, = ax.plot(locs, [yloc]*len(locs), linestyle='', marker=lines.TICKDOWN, **props) axline, = ax.plot([xmin, xmax], [yloc, yloc], **props) @@ -31,7 +31,7 @@ def make_xaxis(ax, yloc, offset=0.05, **props): def make_yaxis(ax, xloc=0, offset=0.05, **props): ymin, ymax = ax.get_ylim() locs = [loc for loc in ax.yaxis.get_majorticklocs() - if loc>=ymin and loc<=ymax] + if loc >= ymin and loc <= ymax] tickline, = ax.plot([xloc]*len(locs), locs, linestyle='', marker=lines.TICKLEFT, **props) axline, = ax.plot([xloc, xloc], [ymin, ymax], **props) diff --git a/examples/pylab_examples/multi_image.py b/examples/pylab_examples/multi_image.py index 1dd706abbb89..8df0e30c2c8d 100644 --- a/examples/pylab_examples/multi_image.py +++ b/examples/pylab_examples/multi_image.py @@ -38,7 +38,7 @@ a.set_xticklabels([]) # Make some fake data with a range that varies # somewhat from one plot to the next. - data =((1+i+j)/10.0)*rand(10, 20)*1e-6 + data = ((1+i+j)/10.0)*rand(10, 20)*1e-6 dd = ravel(data) # Manually find the min and max of all colors for # use in setting the color scale. diff --git a/examples/pylab_examples/newscalarformatter_demo.py b/examples/pylab_examples/newscalarformatter_demo.py index 7b837c220582..3887843bb229 100644 --- a/examples/pylab_examples/newscalarformatter_demo.py +++ b/examples/pylab_examples/newscalarformatter_demo.py @@ -3,8 +3,8 @@ from pylab import * from matplotlib.ticker import OldScalarFormatter -x=frange(0, 1, .01) -f=figure(figsize=(6, 6)) +x = frange(0, 1, .01) +f = figure(figsize=(6, 6)) f.text(0.5, 0.975, 'The old formatter', horizontalalignment='center', verticalalignment='top') subplot(221) plot(x*1e5+1e10, x*1e-10+1e-5) @@ -23,8 +23,8 @@ gca().xaxis.set_major_formatter(OldScalarFormatter()) gca().yaxis.set_major_formatter(OldScalarFormatter()) -x=frange(0, 1, .01) -f=figure(figsize=(6, 6)) +x = frange(0, 1, .01) +f = figure(figsize=(6, 6)) f.text(0.5, 0.975, 'The new formatter, default settings', horizontalalignment='center', verticalalignment='top') subplot(221) @@ -44,8 +44,8 @@ gca().xaxis.set_major_formatter(ScalarFormatter()) gca().yaxis.set_major_formatter(ScalarFormatter()) -x=frange(0, 1, .01) -f=figure(figsize=(6, 6)) +x = frange(0, 1, .01) +f = figure(figsize=(6, 6)) f.text(0.5, 0.975, 'The new formatter, no numerical offset', horizontalalignment='center', verticalalignment='top') subplot(221) @@ -65,8 +65,8 @@ gca().xaxis.set_major_formatter(ScalarFormatter(useOffset=False)) gca().yaxis.set_major_formatter(ScalarFormatter(useOffset=False)) -x=frange(0, 1, .01) -f=figure(figsize=(6, 6)) +x = frange(0, 1, .01) +f = figure(figsize=(6, 6)) f.text(0.5, 0.975, 'The new formatter, with mathtext', horizontalalignment='center', verticalalignment='top') subplot(221) diff --git a/examples/pylab_examples/pie_demo2.py b/examples/pylab_examples/pie_demo2.py index c3cd16fcb37e..920737211cfd 100644 --- a/examples/pylab_examples/pie_demo2.py +++ b/examples/pylab_examples/pie_demo2.py @@ -15,7 +15,7 @@ labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' fracs = [15, 30, 45, 10] -explode=(0, 0.05, 0, 0) +explode = (0, 0.05, 0, 0) # Make square figures and axes diff --git a/examples/pylab_examples/scatter_custom_symbol.py b/examples/pylab_examples/scatter_custom_symbol.py index 55e5627bcc20..d3bec5819b9f 100644 --- a/examples/pylab_examples/scatter_custom_symbol.py +++ b/examples/pylab_examples/scatter_custom_symbol.py @@ -9,7 +9,7 @@ verts = list(zip(rx/area*cos(theta), ry/area*sin(theta))) x, y, s, c = rand(4, 30) -s*= 10**2. +s *= 10**2. fig, ax = plt.subplots() ax.scatter(x, y, s, c, marker=None, verts=verts) diff --git a/examples/pylab_examples/specgram_demo.py b/examples/pylab_examples/specgram_demo.py index d7b735bc2f8f..d5cced232d7b 100644 --- a/examples/pylab_examples/specgram_demo.py +++ b/examples/pylab_examples/specgram_demo.py @@ -7,7 +7,7 @@ s2 = 2*sin(2*pi*400*t) # create a transient "chirp" -mask = where(logical_and(t>10, t<12), 1.0, 0.0) +mask = where(logical_and(t > 10, t < 12), 1.0, 0.0) s2 = s2 * mask # add some noise into the mix diff --git a/examples/pylab_examples/step_demo.py b/examples/pylab_examples/step_demo.py index 6c3bffa363ee..2af6a891eda8 100644 --- a/examples/pylab_examples/step_demo.py +++ b/examples/pylab_examples/step_demo.py @@ -14,7 +14,7 @@ y -= 0.5 step(x, y, where='post', label='post') -y = ma.masked_where((y0>-0.15)&(y0<0.15), y - 0.5) +y = ma.masked_where((y0 > -0.15)&(y0 < 0.15), y - 0.5) step(x, y, label='masked (pre)') legend() diff --git a/examples/pylab_examples/tex_unicode_demo.py b/examples/pylab_examples/tex_unicode_demo.py index 2f3185f076bd..3a77676fb822 100755 --- a/examples/pylab_examples/tex_unicode_demo.py +++ b/examples/pylab_examples/tex_unicode_demo.py @@ -6,8 +6,8 @@ """ from __future__ import unicode_literals import matplotlib as mpl -mpl.rcParams['text.usetex']=True -mpl.rcParams['text.latex.unicode']=True +mpl.rcParams['text.usetex'] = True +mpl.rcParams['text.latex.unicode'] = True from numpy import arange, cos, pi from matplotlib.pyplot import (figure, axes, plot, xlabel, ylabel, title, grid, savefig, show) diff --git a/examples/pylab_examples/usetex_baseline_test.py b/examples/pylab_examples/usetex_baseline_test.py index 2273f9f5f287..f6704e534003 100644 --- a/examples/pylab_examples/usetex_baseline_test.py +++ b/examples/pylab_examples/usetex_baseline_test.py @@ -4,8 +4,8 @@ import matplotlib.axes as maxes from matplotlib import rcParams -rcParams['text.usetex']=True -rcParams['text.latex.unicode']=True +rcParams['text.usetex'] = True +rcParams['text.latex.unicode'] = True class Axes(maxes.Axes): diff --git a/examples/pylab_examples/zorder_demo.py b/examples/pylab_examples/zorder_demo.py index 913aba82be9b..d0837c89b1b7 100755 --- a/examples/pylab_examples/zorder_demo.py +++ b/examples/pylab_examples/zorder_demo.py @@ -32,7 +32,7 @@ scatter(x, y, s=120, zorder=2) # A new figure, with individually ordered items -x=frange(0, 2*pi, npts=100) +x = frange(0, 2*pi, npts=100) figure() plot(x, sin(x), linewidth=10, color='black', label='zorder=10', zorder=10) # on top plot(x, cos(1.3*x), linewidth=10, color='red', label='zorder=1', zorder=1) # bottom diff --git a/examples/specialty_plots/advanced_hillshading.py b/examples/specialty_plots/advanced_hillshading.py index 411a09d98c57..65ab2bc079dc 100644 --- a/examples/specialty_plots/advanced_hillshading.py +++ b/examples/specialty_plots/advanced_hillshading.py @@ -52,7 +52,7 @@ def shade_other_data(): z1 = np.sin(x**2) # Data to hillshade z2 = np.cos(x**2 + y**2) # Data to color - norm=Normalize(z2.min(), z2.max()) + norm = Normalize(z2.min(), z2.max()) cmap = plt.cm.jet ls = LightSource(315, 45) diff --git a/examples/units/bar_demo2.py b/examples/units/bar_demo2.py index 6b2bdf510df4..e7fb8bdde07c 100644 --- a/examples/units/bar_demo2.py +++ b/examples/units/bar_demo2.py @@ -12,9 +12,9 @@ import matplotlib.pyplot as plt -cms = cm *np.arange(0, 10, 2) -bottom=0*cm -width=0.8*cm +cms = cm * np.arange(0, 10, 2) +bottom = 0*cm +width = 0.8*cm fig = plt.figure() diff --git a/examples/units/basic_units.py b/examples/units/basic_units.py index 2182bceae3bf..46c267358d90 100644 --- a/examples/units/basic_units.py +++ b/examples/units/basic_units.py @@ -321,13 +321,13 @@ class BasicUnitConverter(units.ConversionInterface): def axisinfo(unit, axis): 'return AxisInfo instance for x and unit' - if unit==radians: + if unit == radians: return units.AxisInfo( majloc=ticker.MultipleLocator(base=np.pi/2), majfmt=ticker.FuncFormatter(rad_fn), label=unit.fullname, ) - elif unit==degrees: + elif unit == degrees: return units.AxisInfo( majloc=ticker.AutoLocator(), majfmt=ticker.FormatStrFormatter(r'$%i^\circ$'), diff --git a/examples/units/evans_test.py b/examples/units/evans_test.py index 62f6c5e6b4b3..c605cc4170d3 100644 --- a/examples/units/evans_test.py +++ b/examples/units/evans_test.py @@ -24,7 +24,7 @@ class FooConverter(object): @staticmethod def axisinfo(unit, axis): 'return the Foo AxisInfo' - if unit==1.0 or unit==2.0: + if unit == 1.0 or unit == 2.0: return units.AxisInfo( majloc=ticker.IndexLocator(8, 0), majfmt=ticker.FormatStrFormatter("VAL: %s"), diff --git a/examples/units/units_sample.py b/examples/units/units_sample.py index 64de55b5b7a4..84f26490a87f 100644 --- a/examples/units/units_sample.py +++ b/examples/units/units_sample.py @@ -11,7 +11,7 @@ import matplotlib.pyplot as plt import numpy -cms = cm *numpy.arange(0, 10, 2) +cms = cm * numpy.arange(0, 10, 2) fig = plt.figure() diff --git a/examples/user_interfaces/gtk_spreadsheet.py b/examples/user_interfaces/gtk_spreadsheet.py index ee4bf31c43e7..a85657b82506 100644 --- a/examples/user_interfaces/gtk_spreadsheet.py +++ b/examples/user_interfaces/gtk_spreadsheet.py @@ -63,7 +63,7 @@ def __init__(self): self.add_columns() self.add_events(gdk.BUTTON_PRESS_MASK | - gdk.KEY_PRESS_MASK| + gdk.KEY_PRESS_MASK | gdk.KEY_RELEASE_MASK) def plot_row(self, treeview, path, view_column): diff --git a/examples/user_interfaces/interactive.py b/examples/user_interfaces/interactive.py index 7f3c33e993a4..876381ec408c 100755 --- a/examples/user_interfaces/interactive.py +++ b/examples/user_interfaces/interactive.py @@ -214,7 +214,7 @@ def pre_interact(self): map(push, lines) # Execute file if given. - if len(sys.argv)>1: + if len(sys.argv) > 1: import matplotlib matplotlib.interactive(0) # turn off interaction fname = sys.argv[1] @@ -225,7 +225,7 @@ def pre_interact(self): else: print('*** Executing file <%s>:' % fname) for line in inFile: - if line.lstrip().find('show()')==0: continue + if line.lstrip().find('show()') == 0: continue print('>>', line) push(line) inFile.close() @@ -237,7 +237,7 @@ def pre_interact(self): sys.exit() # Quick sys.argv hack to extract the option and leave filenames in sys.argv. # For real option handling, use optparse or getopt. - if len(sys.argv) > 1 and sys.argv[1]=='-pylab': + if len(sys.argv) > 1 and sys.argv[1] == '-pylab': sys.argv = [sys.argv[0]]+sys.argv[2:] MatplotLibInterpreter().mainloop() else: diff --git a/examples/user_interfaces/interactive2.py b/examples/user_interfaces/interactive2.py index b244d8a3453f..de03a04ecd74 100755 --- a/examples/user_interfaces/interactive2.py +++ b/examples/user_interfaces/interactive2.py @@ -224,7 +224,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 == None: self.text.get_buffer().insert(end, text) else: self.text.get_buffer().insert_with_tags(end, text, style) @@ -368,7 +368,7 @@ def key_event(widget, event): console.execute_line('matplotlib.interactive(1)') console.execute_line('from pylab import *') - if len(sys.argv)>1: + if len(sys.argv) > 1: fname = sys.argv[1] if not os.path.exists(fname): print('%s does not exist' % fname) diff --git a/examples/user_interfaces/pylab_with_gtk.py b/examples/user_interfaces/pylab_with_gtk.py index 90a7d7d492d0..99a7133e2f28 100644 --- a/examples/user_interfaces/pylab_with_gtk.py +++ b/examples/user_interfaces/pylab_with_gtk.py @@ -36,7 +36,7 @@ def clicked(button): 'Click me for fun and profit') toolitem.add(button) -toolbar.insert(toolitem, next); next +=1 +toolbar.insert(toolitem, next); next += 1 # now let's add a widget to the vbox label = gtk.Label() diff --git a/examples/user_interfaces/wxcursor_demo.py b/examples/user_interfaces/wxcursor_demo.py index f143ad27cca7..ae3aaae0bcde 100644 --- a/examples/user_interfaces/wxcursor_demo.py +++ b/examples/user_interfaces/wxcursor_demo.py @@ -54,7 +54,7 @@ def UpdateStatusBar(self, event): if event.inaxes: x, y = event.xdata, event.ydata self.statusBar.SetStatusText(("x= " + str(x) + - " y=" +str(y)), + " y=" + str(y)), 0) @@ -66,6 +66,6 @@ def OnInit(self): frame.Show(True) return True -if __name__=='__main__': +if __name__ == '__main__': app = App(0) app.MainLoop() diff --git a/examples/widgets/menu.py b/examples/widgets/menu.py index 24c0c8a440a0..21de51bffc1f 100644 --- a/examples/widgets/menu.py +++ b/examples/widgets/menu.py @@ -47,7 +47,7 @@ def __init__(self, fig, labelstr, props=None, hoverprops=None, x, self.depth = self.parser.to_mask( labelstr, fontsize=props.fontsize, dpi=fig.dpi) - if props.fontsize!=hoverprops.fontsize: + if props.fontsize != hoverprops.fontsize: raise NotImplementedError( 'support for different font sizes not implemented') From 588b5826bd9352f08d67a453b44281a4e0739a81 Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Mon, 27 Oct 2014 21:05:11 +0100 Subject: [PATCH 2/2] e227 e228 Signed-off-by: Thomas Hisch --- examples/event_handling/data_browser.py | 4 ++-- examples/event_handling/pick_event_demo2.py | 2 +- examples/misc/image_thumbnail.py | 6 +++--- examples/pylab_examples/anscombe.py | 2 +- examples/pylab_examples/cursor_demo.py | 6 +++--- examples/pylab_examples/data_helper.py | 2 +- examples/pylab_examples/date_demo1.py | 2 +- examples/pylab_examples/finance_work2.py | 4 ++-- examples/pylab_examples/image_slices_viewer.py | 2 +- examples/pylab_examples/manual_axis.py | 4 ++-- examples/pylab_examples/movie_demo.py | 2 +- examples/pylab_examples/step_demo.py | 2 +- examples/tests/backend_driver.py | 6 +++--- examples/units/basic_units.py | 2 +- examples/user_interfaces/embedding_in_gtk2.py | 2 +- examples/user_interfaces/embedding_in_tk.py | 2 +- examples/user_interfaces/embedding_in_wx3.py | 2 +- examples/user_interfaces/fourier_demo_wx.py | 2 +- examples/user_interfaces/gtk_spreadsheet.py | 2 +- examples/user_interfaces/mpl_with_glade.py | 2 +- examples/user_interfaces/pylab_with_gtk.py | 2 +- examples/user_interfaces/rec_edit_gtk_custom.py | 2 +- examples/user_interfaces/svg_histogram.py | 16 ++++++++-------- examples/user_interfaces/svg_tooltip.py | 8 ++++---- 24 files changed, 43 insertions(+), 43 deletions(-) diff --git a/examples/event_handling/data_browser.py b/examples/event_handling/data_browser.py index 6ba652d88f4b..62a71360e732 100644 --- a/examples/event_handling/data_browser.py +++ b/examples/event_handling/data_browser.py @@ -52,13 +52,13 @@ def update(self): ax2.cla() ax2.plot(X[dataind]) - ax2.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]), + ax2.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f' % (xs[dataind], ys[dataind]), transform=ax2.transAxes, va='top') ax2.set_ylim(-0.5, 1.5) self.selected.set_visible(True) self.selected.set_data(xs[dataind], ys[dataind]) - self.text.set_text('selected: %d'%dataind) + self.text.set_text('selected: %d' % dataind) fig.canvas.draw() diff --git a/examples/event_handling/pick_event_demo2.py b/examples/event_handling/pick_event_demo2.py index 2ef8c75131dd..3223375a7ca7 100644 --- a/examples/event_handling/pick_event_demo2.py +++ b/examples/event_handling/pick_event_demo2.py @@ -27,7 +27,7 @@ def onpick(event): for subplotnum, dataind in enumerate(event.ind): ax = figi.add_subplot(N, 1, subplotnum+1) ax.plot(X[dataind]) - ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]), + ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f' % (xs[dataind], ys[dataind]), transform=ax.transAxes, va='top') ax.set_ylim(-0.5, 1.5) figi.show() diff --git a/examples/misc/image_thumbnail.py b/examples/misc/image_thumbnail.py index aee300426fd9..228ad945dbbe 100644 --- a/examples/misc/image_thumbnail.py +++ b/examples/misc/image_thumbnail.py @@ -11,11 +11,11 @@ if len(sys.argv) != 2: - print('Usage: python %s IMAGEDIR'%__file__) + print('Usage: python %s IMAGEDIR' % __file__) raise SystemExit indir = sys.argv[1] if not os.path.isdir(indir): - print('Could not find input directory "%s"'%indir) + print('Could not find input directory "%s"' % indir) raise SystemExit outdir = 'thumbs' @@ -26,4 +26,4 @@ basedir, basename = os.path.split(fname) outfile = os.path.join(outdir, basename) fig = image.thumbnail(fname, outfile, scale=0.15) - print('saved thumbnail of %s to %s'%(fname, outfile)) + print('saved thumbnail of %s to %s' % (fname, outfile)) diff --git a/examples/pylab_examples/anscombe.py b/examples/pylab_examples/anscombe.py index f8cb98434abf..192dcbd0dbbb 100755 --- a/examples/pylab_examples/anscombe.py +++ b/examples/pylab_examples/anscombe.py @@ -54,6 +54,6 @@ def fit(x): # verify the stats pairs = (x, y1), (x, y2), (x, y3), (x4, y4) for x, y in pairs: - print('mean=%1.2f, std=%1.2f, r=%1.2f'%(mean(y), std(y), corrcoef(x, y)[0][1])) + print('mean=%1.2f, std=%1.2f, r=%1.2f' % (mean(y), std(y), corrcoef(x, y)[0][1])) show() diff --git a/examples/pylab_examples/cursor_demo.py b/examples/pylab_examples/cursor_demo.py index 351ecf8fb101..a5fec0550090 100755 --- a/examples/pylab_examples/cursor_demo.py +++ b/examples/pylab_examples/cursor_demo.py @@ -31,7 +31,7 @@ def mouse_move(self, event): self.lx.set_ydata(y) self.ly.set_xdata(x) - self.txt.set_text('x=%1.2f, y=%1.2f'%(x, y)) + self.txt.set_text('x=%1.2f, y=%1.2f' % (x, y)) draw() @@ -63,8 +63,8 @@ def mouse_move(self, event): self.lx.set_ydata(y) self.ly.set_xdata(x) - self.txt.set_text('x=%1.2f, y=%1.2f'%(x, y)) - print('x=%1.2f, y=%1.2f'%(x, y)) + self.txt.set_text('x=%1.2f, y=%1.2f' % (x, y)) + print('x=%1.2f, y=%1.2f' % (x, y)) draw() t = arange(0.0, 1.0, 0.01) diff --git a/examples/pylab_examples/data_helper.py b/examples/pylab_examples/data_helper.py index d6379559bc61..2e0f2683a45f 100755 --- a/examples/pylab_examples/data_helper.py +++ b/examples/pylab_examples/data_helper.py @@ -40,7 +40,7 @@ class C: pass def get_ticker(ticker): vals = [] - datafile = cbook.get_sample_data('%s.csv'%ticker, asfileobj=False) + datafile = cbook.get_sample_data('%s.csv' % ticker, asfileobj=False) lines = open(datafile).readlines() for line in lines[1:]: diff --git a/examples/pylab_examples/date_demo1.py b/examples/pylab_examples/date_demo1.py index 4bf057b3259a..433fa187691b 100644 --- a/examples/pylab_examples/date_demo1.py +++ b/examples/pylab_examples/date_demo1.py @@ -44,7 +44,7 @@ # 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) diff --git a/examples/pylab_examples/finance_work2.py b/examples/pylab_examples/finance_work2.py index 13eca5e87648..99b41c7f953f 100644 --- a/examples/pylab_examples/finance_work2.py +++ b/examples/pylab_examples/finance_work2.py @@ -119,7 +119,7 @@ def moving_average_convergence(x, nslow=26, nfast=12): ax1.set_ylim(0, 100) ax1.set_yticks([30, 70]) ax1.text(0.025, 0.95, 'RSI (14)', va='top', transform=ax1.transAxes, fontsize=textsize) -ax1.set_title('%s daily'%ticker) +ax1.set_title('%s daily' % ticker) # plot the price and volume data dx = r.adj_close - r.close @@ -171,7 +171,7 @@ def moving_average_convergence(x, nslow=26, nfast=12): ax3.fill_between(r.date, macd-ema9, 0, alpha=0.5, facecolor=fillcolor, edgecolor=fillcolor) -ax3.text(0.025, 0.95, 'MACD (%d, %d, %d)'%(nfast, nslow, nema), va='top', +ax3.text(0.025, 0.95, 'MACD (%d, %d, %d)' % (nfast, nslow, nema), va='top', transform=ax3.transAxes, fontsize=textsize) #ax3.set_yticks([]) diff --git a/examples/pylab_examples/image_slices_viewer.py b/examples/pylab_examples/image_slices_viewer.py index dd4cccb398cd..433b67655836 100644 --- a/examples/pylab_examples/image_slices_viewer.py +++ b/examples/pylab_examples/image_slices_viewer.py @@ -26,7 +26,7 @@ def onscroll(self, event): def update(self): self.im.set_data(self.X[:, :, self.ind]) - ax.set_ylabel('slice %s'%self.ind) + ax.set_ylabel('slice %s' % self.ind) self.im.axes.figure.canvas.draw() diff --git a/examples/pylab_examples/manual_axis.py b/examples/pylab_examples/manual_axis.py index 5c993f45fb5a..21f8518a7477 100644 --- a/examples/pylab_examples/manual_axis.py +++ b/examples/pylab_examples/manual_axis.py @@ -23,7 +23,7 @@ def make_xaxis(ax, yloc, offset=0.05, **props): tickline.set_clip_on(False) axline.set_clip_on(False) for loc in locs: - ax.text(loc, yloc-offset, '%1.1f'%loc, + ax.text(loc, yloc-offset, '%1.1f' % loc, horizontalalignment='center', verticalalignment='top') @@ -39,7 +39,7 @@ def make_yaxis(ax, xloc=0, offset=0.05, **props): axline.set_clip_on(False) for loc in locs: - ax.text(xloc-offset, loc, '%1.1f'%loc, + ax.text(xloc-offset, loc, '%1.1f' % loc, verticalalignment='center', horizontalalignment='right') diff --git a/examples/pylab_examples/movie_demo.py b/examples/pylab_examples/movie_demo.py index 727962910101..0fb0611bfdd0 100755 --- a/examples/pylab_examples/movie_demo.py +++ b/examples/pylab_examples/movie_demo.py @@ -13,7 +13,7 @@ for i in range(50): # 50 frames plt.cla() plt.imshow(np.random.rand(5, 5), interpolation='nearest') - fname = '_tmp%03d.png'%i + fname = '_tmp%03d.png' % i print('Saving frame', fname) plt.savefig(fname) files.append(fname) diff --git a/examples/pylab_examples/step_demo.py b/examples/pylab_examples/step_demo.py index 2af6a891eda8..5c826192bf7f 100644 --- a/examples/pylab_examples/step_demo.py +++ b/examples/pylab_examples/step_demo.py @@ -14,7 +14,7 @@ y -= 0.5 step(x, y, where='post', label='post') -y = ma.masked_where((y0 > -0.15)&(y0 < 0.15), y - 0.5) +y = ma.masked_where((y0 > -0.15) & (y0 < 0.15), y - 0.5) step(x, y, label='masked (pre)') legend() diff --git a/examples/tests/backend_driver.py b/examples/tests/backend_driver.py index d8e9874534fe..a183e353f859 100755 --- a/examples/tests/backend_driver.py +++ b/examples/tests/backend_driver.py @@ -330,7 +330,7 @@ def report_missing(dir, flist): missing = list(pyfiles-flist-exclude) missing.sort() if missing: - print('%s files not tested: %s'%(dir, ', '.join(missing))) + print('%s files not tested: %s' % (dir, ', '.join(missing))) def report_all_missing(directories): @@ -386,7 +386,7 @@ def drive(backend, directories, python=['python'], switches=[]): fpath, fname = os.path.split(fullpath) if fname in exclude: - print('\tSkipping %s, known to fail on backend: %s'%backend) + print('\tSkipping %s, known to fail on backend: %s' % backend) continue basename, ext = os.path.splitext(fname) @@ -492,7 +492,7 @@ def parse_options(): for d in localdirs: if d.lower() not in all_backends_set: continue - print('removing %s'%d) + print('removing %s' % d) for fname in glob.glob(os.path.join(d, '*')): os.remove(fname) os.rmdir(d) diff --git a/examples/units/basic_units.py b/examples/units/basic_units.py index 46c267358d90..2469882ff159 100644 --- a/examples/units/basic_units.py +++ b/examples/units/basic_units.py @@ -201,7 +201,7 @@ def __init__(self, name, fullname=None): self.conversions = dict() def __repr__(self): - return 'BasicUnit(%s)'%self.name + return 'BasicUnit(%s)' % self.name def __str__(self): return self.fullname diff --git a/examples/user_interfaces/embedding_in_gtk2.py b/examples/user_interfaces/embedding_in_gtk2.py index 47a17ecc3398..898f5ea88633 100644 --- a/examples/user_interfaces/embedding_in_gtk2.py +++ b/examples/user_interfaces/embedding_in_gtk2.py @@ -43,7 +43,7 @@ def on_key_event(event): - print('you pressed %s'%event.key) + print('you pressed %s' % event.key) key_press_handler(event, canvas, toolbar) canvas.mpl_connect('key_press_event', on_key_event) diff --git a/examples/user_interfaces/embedding_in_tk.py b/examples/user_interfaces/embedding_in_tk.py index ce725c9bc768..4c93d25a9c84 100755 --- a/examples/user_interfaces/embedding_in_tk.py +++ b/examples/user_interfaces/embedding_in_tk.py @@ -40,7 +40,7 @@ def on_key_event(event): - print('you pressed %s'%event.key) + print('you pressed %s' % event.key) key_press_handler(event, canvas, toolbar) canvas.mpl_connect('key_press_event', on_key_event) diff --git a/examples/user_interfaces/embedding_in_wx3.py b/examples/user_interfaces/embedding_in_wx3.py index d89529c1d8bc..b2ddc52551b2 100755 --- a/examples/user_interfaces/embedding_in_wx3.py +++ b/examples/user_interfaces/embedding_in_wx3.py @@ -56,7 +56,7 @@ def __init__(self, parent): # Now put all into a sizer sizer = wx.BoxSizer(wx.VERTICAL) # This way of adding to sizer allows resizing - sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW) + sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) # Best to allow the toolbar to resize! sizer.Add(self.toolbar, 0, wx.GROW) self.SetSizer(sizer) diff --git a/examples/user_interfaces/fourier_demo_wx.py b/examples/user_interfaces/fourier_demo_wx.py index 0c7b4b4b6a33..c0c718799e99 100644 --- a/examples/user_interfaces/fourier_demo_wx.py +++ b/examples/user_interfaces/fourier_demo_wx.py @@ -90,7 +90,7 @@ def sliderTextHandler(self, evt): self.param.set(value) def setKnob(self, value): - self.sliderText.SetValue('%g'%value) + self.sliderText.SetValue('%g' % value) self.slider.SetValue(value*1000) diff --git a/examples/user_interfaces/gtk_spreadsheet.py b/examples/user_interfaces/gtk_spreadsheet.py index a85657b82506..efe2e43cf701 100644 --- a/examples/user_interfaces/gtk_spreadsheet.py +++ b/examples/user_interfaces/gtk_spreadsheet.py @@ -74,7 +74,7 @@ def plot_row(self, treeview, path, view_column): def add_columns(self): for i in range(self.numCols): - column = gtk.TreeViewColumn('%d'%i, gtk.CellRendererText(), text=i) + column = gtk.TreeViewColumn('%d' % i, gtk.CellRendererText(), text=i) self.treeview.append_column(column) def create_model(self): diff --git a/examples/user_interfaces/mpl_with_glade.py b/examples/user_interfaces/mpl_with_glade.py index f9ba2902512e..a2209a8310ba 100755 --- a/examples/user_interfaces/mpl_with_glade.py +++ b/examples/user_interfaces/mpl_with_glade.py @@ -62,7 +62,7 @@ def __init__(self): gtk.gdk.KEY_PRESS_MASK | gtk.gdk.KEY_RELEASE_MASK ) - self.canvas.set_flags(gtk.HAS_FOCUS|gtk.CAN_FOCUS) + self.canvas.set_flags(gtk.HAS_FOCUS | gtk.CAN_FOCUS) self.canvas.grab_focus() def keypress(widget, event): diff --git a/examples/user_interfaces/pylab_with_gtk.py b/examples/user_interfaces/pylab_with_gtk.py index 99a7133e2f28..03e3be507f57 100644 --- a/examples/user_interfaces/pylab_with_gtk.py +++ b/examples/user_interfaces/pylab_with_gtk.py @@ -51,7 +51,7 @@ def update(event): if event.xdata is None: label.set_markup('Drag mouse over axes for position') else: - label.set_markup('x,y=(%f, %f)'%(event.xdata, event.ydata)) + label.set_markup('x,y=(%f, %f)' % (event.xdata, event.ydata)) plt.connect('motion_notify_event', update) diff --git a/examples/user_interfaces/rec_edit_gtk_custom.py b/examples/user_interfaces/rec_edit_gtk_custom.py index 2d88978508e5..0d3a20374816 100644 --- a/examples/user_interfaces/rec_edit_gtk_custom.py +++ b/examples/user_interfaces/rec_edit_gtk_custom.py @@ -30,7 +30,7 @@ def mycallback(liststore, rownum, colname, oldval, newval): - print('verify: old=%s, new=%s, rec=%s'%(oldval, newval, liststore.r[rownum][colname])) + print('verify: old=%s, new=%s, rec=%s' % (oldval, newval, liststore.r[rownum][colname])) liststore.callbacks.connect('cell_changed', mycallback) diff --git a/examples/user_interfaces/svg_histogram.py b/examples/user_interfaces/svg_histogram.py index ec3d714ac973..9e5c3bc74d97 100755 --- a/examples/user_interfaces/svg_histogram.py +++ b/examples/user_interfaces/svg_histogram.py @@ -62,18 +62,18 @@ hist_patches = {} for ic, c in enumerate(containers): - hist_patches['hist_%d'%ic] = [] + hist_patches['hist_%d' % ic] = [] for il, element in enumerate(c): - element.set_gid('hist_%d_patch_%d'%(ic, il)) - hist_patches['hist_%d'%ic].append('hist_%d_patch_%d'%(ic, il)) + element.set_gid('hist_%d_patch_%d' % (ic, il)) + hist_patches['hist_%d' %ic].append('hist_%d_patch_%d' % (ic, il)) # Set ids for the legend patches for i, t in enumerate(leg.get_patches()): - t.set_gid('leg_patch_%d'%i) + t.set_gid('leg_patch_%d' % i) # Set ids for the text patches for i, t in enumerate(leg.get_texts()): - t.set_gid('leg_text_%d'%i) + t.set_gid('leg_text_%d' % i) # Save SVG in a fake file object. f = StringIO() @@ -87,13 +87,13 @@ # Add attributes to the patch objects. for i, t in enumerate(leg.get_patches()): - el = xmlid['leg_patch_%d'%i] + el = xmlid['leg_patch_%d' % i] el.set('cursor', 'pointer') el.set('onclick', "toggle_hist(this)") # Add attributes to the text objects. for i, t in enumerate(leg.get_texts()): - el = xmlid['leg_text_%d'%i] + el = xmlid['leg_text_%d' % i] el.set('cursor', 'pointer') el.set('onclick', "toggle_hist(this)") @@ -142,7 +142,7 @@ } ]]> -"""%json.dumps(hist_patches) +""" % json.dumps(hist_patches) # Add a transition effect css = tree.getchildren()[0][0] diff --git a/examples/user_interfaces/svg_tooltip.py b/examples/user_interfaces/svg_tooltip.py index 401e42403782..5e2c7382b657 100644 --- a/examples/user_interfaces/svg_tooltip.py +++ b/examples/user_interfaces/svg_tooltip.py @@ -59,11 +59,11 @@ # Set id for the patches for i, t in enumerate(ax.patches): - t.set_gid('patch_%d'%i) + t.set_gid('patch_%d' % i) # Set id for the annotations for i, t in enumerate(ax.texts): - t.set_gid('tooltip_%d'%i) + t.set_gid('tooltip_%d' % i) # Save the figure in a fake file object @@ -82,12 +82,12 @@ # Hide the tooltips for i, t in enumerate(ax.texts): - el = xmlid['tooltip_%d'%i] + el = xmlid['tooltip_%d' % i] el.set('visibility', 'hidden') # Assign onmouseover and onmouseout callbacks to patches. for i, t in enumerate(ax.patches): - el = xmlid['patch_%d'%i] + el = xmlid['patch_%d' % i] el.set('onmouseover', "ShowTooltip(this)") el.set('onmouseout', "HideTooltip(this)")