8000 STY: Various pep8 fixes - specifically targeting travis pep8 failures · matplotlib/matplotlib@9b0af8a · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b0af8a

Browse files
committed
STY: Various pep8 fixes - specifically targeting travis pep8 failures
1 parent 612b3f2 commit 9b0af8a

File tree

7 files changed

+49
-54
lines changed

7 files changed

+49
-54
lines changed

examples/pylab_examples/demo_annotation_box.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
boxcoords=("axes fraction", "data"),
4444
box_alignment=(0., 0.5),
4545
arrowprops=dict(arrowstyle="->"))
46-
#arrowprops=None)
4746

4847
ax.add_artist(ab)
4948

@@ -56,7 +55,6 @@
5655
boxcoords="offset points",
5756
pad=0.3,
5857
arrowprops=dict(arrowstyle="->"))
59-
#arrowprops=None)
6058

6159
ax.add_artist(ab)
6260

examples/pylab_examples/multipage_pdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
x = np.arange(0, 5, 0.1)
2424
plt.plot(x, np.sin(x), 'b-')
2525
plt.title('Page Two')
26-
pdf.attach_note("plot of sin(x)") # you can add a pdf note to
27-
# attach metadata to a page
26+
# you can add a pdf note to attach metadata to a page
27+
pdf.attach_note("plot of sin(x)")
2828
pdf.savefig()
2929
plt.close()
3030

examples/pylab_examples/tricontour_smooth_delaunay.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,19 @@ def experiment_res(x, y):
4545
# User parameters for data test points
4646
n_test = 200 # Number of test data points, tested from 3 to 5000 for subdiv=3
4747

48-
subdiv = 3 # Number of recursive subdivisions of the initial mesh for smooth
49-
# plots. Values >3 might result in a very high number of triangles
50-
# for the refine mesh: new triangles numbering = (4**subdiv)*ntri
51-
52-
init_mask_frac = 0.0 # Float > 0. adjusting the proportion of
53-
# (invalid) initial triangles which will be masked
54-
# out. Enter 0 for no mask.
55-
56-
min_circle_ratio = .01 # Minimum circle ratio - border triangles with circle
57-
# ratio below this will be masked if they touch a
58-
# border. Suggested value 0.01 ; Use -1 to keep
59-
# all triangles.
48+
# Number of recursive subdivisions of the initial mesh for smooth plots.
49+
# Values >3 might result in a very high number of triangles for the refine
50+
# mesh: new triangles numbering = (4**subdiv)*ntri
51+
subdiv = 3
52+
53+
# Float > 0. adjusting the proportion of (invalid) initial triangles which will
54+
# be masked out. Enter 0 for no mask.
55+
init_mask_frac = 0.0
56+
57+
# Minimum circle ratio - border triangles with circle ratio below this will
58+
# be masked if they touch a border. Suggested value 0.01; Use -1 to keep
59+
# all triangles.
60+
min_circle_ratio = .01
6061

6162
# Random points
6263
random_gen = np.random.mtrand.RandomState(seed=127260)

examples/user_interfaces/embedding_in_tk.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ def on_key_event(event):
4848

4949
def _quit():
5050
root.quit() # stops mainloop
51-
root.destroy() # this is necessary on Windows to prevent
52-
# Fatal Python Error: PyEval_RestoreThread: NULL tstate
51+
# this is necessary on Windows to prevent
52+
# Fatal Python Error: PyEval_RestoreThread: NULL tstate
53+
root.destroy()
5354

5455
button = Tk.Button(master=root, text='Quit', command=_quit)
5556
button.pack(side=Tk.BOTTOM)

lib/matplotlib/cm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def revcmap(data):
3737
for key, val in six.iteritems(data):
3838
if six.callable(val):
3939
valnew = _reverser(val)
40-
# This doesn't work: lambda x: val(1-x)
41-
# The same "val" (the first one) is used
42-
# each time, so the colors are identical
43-
# and the result is shades of gray.
40+
# This doesn't work: lambda x: val(1-x)
41+
# The same "val" (the first one) is used
42+
# each time, so the colors are identical
43+
# and the result is shades of gray.
4444
else:
4545
# Flip x and exchange the y values facing x = 0 and x = 1.
4646
valnew = [(1.0 - x, y1, y0) for x, y0, y1 in reversed(val)]

lib/matplotlib/colors.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,8 @@ def makeMappingArray(N, data, gamma=1.0):
482482
lut[-1] = y0[-1]
483483
# ensure that the lut is confined to values between 0 and 1 by clipping it
484484
np.clip(lut, 0.0, 1.0)
485-
#lut = where(lut > 1., 1., lut)
486-
#lut = where(lut < 0., 0., lut)
485+
# lut = where(lut > 1., 1., lut)
486+
# lut = where(lut < 0., 0., lut)
487487
return lut
488488

489489

@@ -614,9 +614,9 @@ def __call__(self, X, alpha=None, bytes=False):
614614

615615
rgba = np.empty(shape=xa.shape + (4,), dtype=lut.dtype)
616616
lut.take(xa, axis=0, mode='clip', out=rgba)
617-
# twice as fast as lut[xa];
618-
# using the clip or wrap mode and providing an
619-
# output array speeds it up a little more.
617+
# twice as fast as lut[xa];
618+
# using the clip or wrap mode and providing an
619+
# output array speeds it up a little more.
620620
if vtype == 'scalar':
621621
rgba = tuple(rgba[0, :])
622622
return rgba
@@ -810,8 +810,8 @@ def __init__(self, colors, name='from_list', N=None):
810810
the list will be extended by repetition.
811811
"""
812812
self.colors = colors
813-
self.monochrome = False # True only if all colors in map are
814-
# identical; needed for contouring.
813+
# True only if all colors in map are identical; needed for contouring.
814+
self.monochrome = False
815815
if N is None:
816816
N = len(self.colors)
817817
else:
@@ -1384,13 +1384,13 @@ def hsv_to_rgb(hsv):
13841384
rgb : (..., 3) ndarray
13851385
Colors converted to RGB values in range [0, 1]
13861386
"""
1387-
# make sure it is an ndarray
1387+
# make sure it is an ndarray
13881388
hsv = np.asarray(hsv)
13891389

13901390
# check length of the last dimension, should be _some_ sort of rgb
13911391
if hsv.shape[-1] != 3:
13921392
raise ValueError("Last dimension of input array must be 3; "
1393-
"shape {shp} was found.".format(shp=hsv.shape))
1393+
"shape {shp} was found.".format(shp=hsv.shape))
13941394

13951395
# if we got pased a 1D array, try to treat as
13961396
# a single color and reshape as needed
@@ -1551,20 +1551,20 @@ def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
15511551
# consistent to what `imshow` assumes, as well.
15521552
dy = -dy
15531553

1554-
#-- Calculate the intensity from the illumination angle
1554+
# Calculate the intensity from the illumination angle
15551555
dy, dx = np.gradient(vert_exag * elevation, dy, dx)
15561556
# The aspect is defined by the _downhill_ direction, thus the negative
15571557
aspect = np.arctan2(-dy, -dx)
15581558
slope = 0.5 * np.pi - np.arctan(np.hypot(dx, dy))
1559-
intensity = (np.sin(alt) * np.sin(slope)
1560-
+ np.cos(alt) * np.cos(slope)
1561-
* np.cos(az - aspect))
1559+
intensity = (np.sin(alt) * np.sin(slope) +
1560+
np.cos(alt) * np.cos(slope) *
1561+
np.cos(az - aspect))
15621562

1563-
#-- Apply contrast stretch
1563+
# Apply contrast stretch
15641564
imin, imax = intensity.min(), intensity.max()
15651565
intensity *= fraction
15661566

1567-
#-- Rescale to 0-1, keeping range before contrast stretch
1567+
# Rescale to 0-1, keeping range before contrast stretch
15681568
# If constant slope, keep relative scaling (i.e. flat should be 0.5,
15691569
# fully occluded 0, etc.)
15701570
if (imax - imin) > 1e-6:

lib/matplotlib/image.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,10 @@ def _draw_unsampled_image(self, renderer, gc):
331331

332332
if numrows <= 0 or numcols <= 0:
333333
return
334-
im.resize(numcols, numrows) # just to create im.bufOut that
335-
# is required by backends. There
336-
# may be better solution -JJL
334+
335+
# just to create im.bufOut that is required by backends. There may be
336+
# a better solution -JJL
337+
im.resize(numcols, numrows)
337338

338339
im._url = self.get_url()
339340
im._gid = self.get_gid()
@@ -353,7 +354,7 @@ def draw(self, renderer, *args, **kwargs):
353354
if not self.get_visible():
354355
return
355356
if (self.axes.get_xscale() != 'linear' or
356-
self.axes.get_yscale() != 'linear'):
357+
self.axes.get_yscale() != 'linear'):
357358
warnings.warn("Images are not supported on non-linear axes.")
358359

359360
l, b, widthDisplay, heightDisplay = self.axes.bbox.bounds
@@ -392,7 +393,7 @@ def contains(self, mouseevent):
392393
xmin, xmax = xmax, xmin
393394
if ymin > ymax:
394395
ymin, ymax = ymax, ymin
395-
#print x, y, xmin, xmax, ymin, ymax
396+
396397
if x is not None and y is not None:
397398
inside = ((x >= xmin) and (x <= xmax) and
398399
(y >= ymin) and (y <= ymax))
@@ -426,11 +427,11 @@ def set_data(self, A):
426427
self._A = cbook.safe_masked_invalid(A)
427428

428429
if (self._A.dtype != np.uint8 and
429-
not np.can_ F438 cast(self._A.dtype, np.float)):
430+
not np.can_cast(self._A.dtype, np.float)):
430431
raise TypeError("Image data can not convert to float")
431432

432433
if (self._A.ndim not in (2, 3) or
433-
(self._A.ndim == 3 and self._A.shape[-1] not in (3, 4))):
434+
(self._A.ndim == 3 and self._A.shape[-1] not in (3, 4))):
434435
raise TypeError("Invalid dimensions for image data")
435436

436437
self._imcache = None
@@ -677,7 +678,6 @@ def get_extent(self):
677678
return self._extent
678679
else:
679680
sz = self.get_size()
680-
#print 'sz', sz
681681
numrows, numcols = sz
682682
if self.origin == 'upper':
683683
return (-0.5, numcols-0.5, numrows-0.5, -0.5)
@@ -914,7 +914,7 @@ def set_data(self, x, y, A):
914914
if A.ndim == 3:
915915
if A.shape[2] in [3, 4]:
916916
if ((A[:, :, 0] == A[:, :, 1]).all() and
917-
(A[:, :, 0] == A[:, :, 2]).all()):
917+
(A[:, :, 0] == A[:, :, 2]).all()):
918918
self.is_grayscale = True
919919
else:
920920
raise ValueError("3D arrays must have RGB or RGBA as last dim")
@@ -972,7 +972,7 @@ def contains(self, mouseevent):
972972
return self._contains(self, mouseevent)
973973
xmin, xmax, ymin, ymax = self.get_extent()
974974
xdata, ydata = mouseevent.x, mouseevent.y
975-
#print xdata, ydata, xmin, xmax, ymin, ymax
975+
976976
if xdata is not None and ydata is not None:
977977
inside = ((xdata >= xmin) and (xdata <= xmax) and
978978
(ydata >= ymin) and (ydata <= ymax))
@@ -1014,7 +1014,6 @@ def make_image(self, magnification=1.0):
10141014
self.magnification = magnification
10151015
# if magnification is not one, we need to resize
10161016
ismag = magnification != 1
1017-
#if ismag: raise RuntimeError
10181017
if ismag:
10191018
isoutput = 0
10201019
else:
@@ -1170,16 +1169,13 @@ def make_image(self, renderer, magnification=1.0):
11701169
numrows, numcols = self._A.shape[:2]
11711170

11721171
if (not self.interp_at_native and
1173-
widthDisplay == numcols and heightDisplay == numrows):
1172+
widthDisplay == numcols and heightDisplay == numrows):
11741173
im.set_interpolation(0)
11751174

11761175
# resize viewport to display
11771176
rx = widthDisplay / numcols
11781177
ry = heightDisplay / numrows
1179-
#im.apply_scaling(rx*sx, ry*sy)
11801178
im.apply_scaling(rx, ry)
1181-
#im.resize(int(widthDisplay+0.5), int(heightDisplay+0.5),
1182-
# norm=self._filternorm, radius=self._filterrad)
11831179
im.resize(int(widthDisplay), int(heightDisplay),
11841180
norm=self._filternorm, radius=self._filterrad)
11851181
return im
@@ -1195,7 +1191,6 @@ def draw(self, renderer, *args, **kwargs):
11951191
gc = renderer.new_gc()
11961192
self._set_gc_clip(gc)
11971193
gc.set_alpha(self.get_alpha())
1198-
#gc.set_clip_path(self.get_clip_path())
11991194

12001195
l = np.min([x0, x1])
12011196
b = np.min([y0, y1])
@@ -1341,7 +1336,7 @@ def toarray(im, dtype=np.uint8):
13411336
x.shape = im.size[1], im.size[0]
13421337
return x
13431338
elif pilImage.mode == 'RGB':
1344-
#return MxNx3 RGB array
1339+
# return MxNx3 RGB array
13451340
im = pilImage # no need to RGB images
13461341
x = toarray(im)
13471342
x.shape = im.size[1], im.size[0], 3

0 commit comments

Comments
 (0)
0