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

Skip to content

Commit 917efaa

Browse files
committed
Merge pull request #4155 from cimarronm/travis_pep8_fixes
Various pep8 fixes - specifically targeting files which are failing travis pep8 tests
2 parents 2de5c33 + dfed541 commit 917efaa

File tree

13 files changed

+154
-198
lines changed

13 files changed

+154
-198
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

lib/matplotlib/axes/_axes.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,7 +2807,7 @@ def xywhere(xs, ys, mask):
28072807

28082808
if yerr is not None:
28092809
if (iterable(yerr) and len(yerr) == 2 and
2810-
iterable(yerr[0]) and iterable(yerr[1])):
2810+
iterable(yerr[0]) and iterable(yerr[1])):
28112811
# using list comps rather than arrays to preserve units
28122812
lower = [thisy - thiserr for (thisy, thiserr)
28132813
in cbook.safezip(y, yerr[0])]
@@ -3066,8 +3066,7 @@ def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,
30663066
# compatibility
30673067
if sym == '':
30683068
# blow away existing dict and make one for invisible markers
3069-
flierprops = dict(linestyle='none', marker='',
3070-
color='none')
3069+
flierprops = dict(linestyle='none', marker='', color='none')
30713070
# turn the fliers off just to be safe
30723071
showfliers = False
30733072
# now process the symbol string
@@ -3088,7 +3087,7 @@ def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,
30883087
# replace medians if necessary:
30893088
if usermedians is not None:
30903089
if (len(np.ravel(usermedians)) != len(bxpstats) or
3091-
np.shape(usermedians)[0] != len(bxpstats)):
3090+
np.shape(usermedians)[0] != len(bxpstats)):
30923091
medmsg = 'usermedians length not compatible with x'
30933092
raise ValueError(medmsg)
30943093
else:
@@ -4680,8 +4679,8 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
46804679
aspect = rcParams['image.aspect']
46814680
self.set_aspect(aspect)
46824681
im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,
4683-
filternorm=filternorm,
4684-
filterrad=filterrad, resample=resample, **kwargs)
4682+
filternorm=filternorm, filterrad=filterrad,
4683+
resample=resample, **kwargs)
46854684

46864685
im.set_data(X)
46874686
im.set_alpha(alpha)
@@ -4966,7 +4965,7 @@ def pcolor(self, *args, **kwargs):
49664965
X3[:, newaxis], Y3[:, newaxis],
49674966
X4[:, newaxis], Y4[:, newaxis],
49684967
X1[:, newaxis], Y1[:, newaxis]),
4969-
axis=1)
4968+
axis=1)
49704969
verts = xy.reshape((npoly, 5, 2))
49714970

49724971
C = compress(ravelmask, ma.filled(C[0:Ny - 1, 0:Nx - 1]).ravel())
@@ -4992,7 +4991,7 @@ def pcolor(self, *args, **kwargs):
49924991
if 'antialiased' in kwargs:
49934992
kwargs['antialiaseds'] = kwargs.pop('antialiased')
49944993
if 'antialiaseds' not in kwargs and (is_string_like(ec) and
4995-
ec.lower() == "none"):
4994+
ec.lower() == "none"):
49964995
kwargs['antialiaseds'] = False
49974996

49984997
kwargs.setdefault('snap', False)
@@ -5014,8 +5013,8 @@ def pcolor(self, *args, **kwargs):
50145013

50155014
# Transform from native to data coordinates?
50165015
t = collection._transform
5017-
if (not isinstance(t, mtransforms.Transform)
5018-
and hasattr(t, '_as_mpl_transform')):
5016+
if (not isinstance(t, mtransforms.Transform) and
5017+
hasattr(t, '_as_mpl_transform')):
50195018
t = t._as_mpl_transform(self.axes)
50205019

50215020
if t and any(t.contains_branch_seperately(self.transData)):
@@ -5161,8 +5160,8 @@ def pcolormesh(self, *args, **kwargs):
51615160

51625161
# Transform from native to data coordinates?
51635162
t = collection._transform
5164-
if (not isinstance(t, mtransforms.Transform)
5165-
and hasattr(t, '_as_mpl_transform')):
5163+
if (not isinstance(t, mtransforms.Transform) and
5164+
hasattr(t, '_as_mpl_transform')):
51665165
t = t._as_mpl_transform(self.axes)
51675166

51685167
if t and any(t.contains_branch_seperately(self.transData)):
@@ -5310,8 +5309,9 @@ def pcolorfast(self, *args, **kwargs):
53105309

53115310
# convert to one dimensional arrays
53125311
# This should also be moved to the QuadMesh class
5313-
C = ma.ravel(C) # data point in each cell is value
5314-
# at lower left corner
5312+
5313+
# data point in each cell is value at lower left corner
5314+
C = ma.ravel(C)
53155315
X = x.ravel()
53165316
Y = y.ravel()
53175317
Nx = nc + 1

lib/matplotlib/axes/_base.py

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,10 @@ def cla(self):
906906
self.containers = []
907907

908908
self.grid(self._gridOn, which=rcParams['axes.grid.which'])
909-
props = font_manager.FontProperties(size=rcParams['axes.titlesize'],
910-
weight=rcParams['axes.titleweight'])
909+
props = font_manager.FontProperties(
910+
size=rcParams['axes.titlesize'],
911+
weight=rcParams['axes.titleweight']
912+
)
911913

912914
self.titleOffsetTrans = mtransforms.ScaledTranslation(
913915
0.0, 5.0 / 72.0, self.figure.dpi_scale_trans)
@@ -1179,7 +1181,7 @@ def apply_aspect(self, position=None):
11791181
else:
11801182
A = aspect
11811183

1182-
#Ensure at drawing time that any Axes involved in axis-sharing
1184+
# Ensure at drawing time that any Axes involved in axis-sharing
11831185
# does not have its position changed.
11841186
if self in self._shared_x_axes or self in self._shared_y_axes:
11851187
if self._adjustable == 'box':
@@ -1218,10 +1220,8 @@ def apply_aspect(self, position=None):
12181220
data_ratio = box_aspect / A
12191221

12201222
y_expander = (data_ratio * xsize / ysize - 1.0)
1221-
#print 'y_expander', y_expander
12221223
# If y_expander > 0, the dy/dx viewLim ratio needs to increase
12231224
if abs(y_expander) < 0.005:
1224-
#print 'good enough already'
12251225
return
12261226

12271227
if aspect_scale_mode == "log":
@@ -1241,30 +1241,25 @@ def apply_aspect(self, position=None):
12411241
Xsize = ysize / data_ratio
12421242
Xmarg = Xsize - xr
12431243
Ymarg = Ysize - yr
1244-
xm = 0 # Setting these targets to, e.g., 0.05*xr does not seem to
1245-
# help.
1244+
xm = 0 # Setting these targets to, e.g., 0.05*xr does not seem to help
12461245
ym = 0
1247-
#print 'xmin, xmax, ymin, ymax', xmin, xmax, ymin, ymax
1248-
#print 'xsize, Xsize, ysize, Ysize', xsize, Xsize, ysize, Ysize
12491246

1250-
changex = (self in self._shared_y_axes
1251-
and self not in self._shared_x_axes)
1252-
changey = (self in self._shared_x_axes
1253-
and self not in self._shared_y_axes)
1247+
changex = (self in self._shared_y_axes and
1248+
self not in self._shared_x_axes)
1249+
changey = (self in self._shared_x_axes and
1250+
self not in self._shared_y_axes)
12541251
if changex and changey:
12551252
warnings.warn("adjustable='datalim' cannot work with shared "
12561253
"x and y axes")
12571254
return
12581255
if changex:
12591256
adjust_y = False
12601257
else:
1261-
#print 'xmarg, ymarg, Xmarg, Ymarg', xmarg, ymarg, Xmarg, Ymarg
12621258
if xmarg > xm and ymarg > ym:
1263-
adjy = ((Ymarg > 0 and y_expander < 0)
1264-
or (Xmarg < 0 and y_expander > 0))
1259+
adjy = ((Ymarg > 0 and y_expander < 0) or
1260+
(Xmarg < 0 and y_expander > 0))
12651261
else:
12661262
adjy = y_expander > 0
1267-
#print 'y_expander, adjy', y_expander, adjy
12681263
adjust_y = changey or adjy # (Ymarg > xmarg)
12691264
if adjust_y:
12701265
yc = 0.5 * (ymin + ymax)
@@ -1274,8 +1269,6 @@ def apply_aspect(self, position=None):
12741269
self.set_ybound((10. ** y0, 10. ** y1))
12751270
else:
12761271
self.set_ybound((y0, y1))
1277-
#print 'New y0, y1:', y0, y1
1278-
#print 'New ysize, ysize/xsize', y1-y0, (y1-y0)/xsize
12791272
else:
12801273
xc = 0.5 * (xmin + xmax)
12811274
x0 = xc - Xsize / 2.0
@@ -1284,8 +1277,6 @@ def apply_aspect(self, position=None):
12841277
self.set_xbound((10. ** x0, 10. ** x1))
12851278
else:
12861279
self.set_xbound((x0, x1))
1287-
#print 'New x0, x1:', x0, x1
1288-
#print 'New xsize, ysize/xsize', x1-x0, ysize/(x1-x0)
12891280

12901281
def axis(self, *v, **kwargs):
12911282
"""
@@ -1402,7 +1393,7 @@ def get_yticklines(self):
14021393
return cbook.silent_list('Line2D ytickline',
14031394
self.yaxis.get_ticklines())
14041395

1405-
#### Adding and tracking artists
1396+
# Adding and tracking artists
14061397

14071398
def _sci(self, im):
14081399
"""
@@ -1588,7 +1579,7 @@ def _update_patch_limits(self, patch):
15881579
xys = patch.get_patch_transform().transform(vertices)
15891580
if patch.get_data_transform() != self.transData:
15901581
patch_to_data = (patch.get_data_transform() -
1591-
self.transData)
1582+
self.transData)
15921583
xys = patch_to_data.transform(xys)
15931584

15941585
updatex, updatey = patch.get_transform().\
@@ -1689,26 +1680,22 @@ def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):
16891680
if self.xaxis is None or self.yaxis is None:
16901681
return
16911682

1692-
#print 'processing', self.get_geometry()
16931683
if xdata is not None:
16941684
# we only need to update if there is nothing set yet.
16951685
if not self.xaxis.have_units():
16961686
self.xaxis.update_units(xdata)
1697-
#print '\tset from xdata', self.xaxis.units
16981687

16991688
if ydata is not None:
17001689
# we only need to update if there is nothing set yet.
17011690
if not self.yaxis.have_units():
17021691
self.yaxis.update_units(ydata)
1703-
#print '\tset from ydata', self.yaxis.units
17041692

17051693
# process kwargs 2nd since these will override default units
17061694
if kwargs is not None:
17071695
xunits = kwargs.pop('xunits', self.xaxis.units)
17081696
if self.name == 'polar':
17091697
xunits = kwargs.pop('thetaunits', xunits)
17101698
if xunits != self.xaxis.units:
1711-
#print '\tkw setting xunits', xunits
17121699
self.xaxis.set_units(xunits)
17131700
# If the units being set imply a different converter,
17141701
# we need to update.
@@ -1719,7 +1706,6 @@ def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):
17191706
if self.name == 'polar':
17201707
yunits = kwargs.pop('runits', yunits)
17211708
if yunits != self.yaxis.units:
1722-
#print '\tkw setting yunits', yunits
17231709
self.yaxis.set_units(yunits)
17241710
# If the units being set imply a different converter,
17251711
# we need to update.
@@ -1937,7 +1923,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
19371923
if scalex and self._autoscaleXon:
19381924
xshared = self._shared_x_axes.get_siblings(self)
19391925
dl = [ax.dataLim for ax in xshared]
1940-
#ignore non-finite data limits if good limits exist
1926+
# ignore non-finite data limits if good limits exist
19411927
finite_dl = [d for d in dl if np.isfinite(d).all()]
19421928
if len(finite_dl):
19431929
dl = finite_dl
@@ -1963,7 +1949,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
19631949
if scaley and self._autoscaleYon:
19641950
yshared = self._shared_y_axes.get_siblings(self)
19651951
dl = [ax.dataLim for ax in yshared]
1966-
#ignore non-finite data limits if good limits exist
1952+
# ignore non-finite data limits if good limits exist
19671953
finite_dl = [d for d in dl if np.isfinite(d).all()]
19681954
if len(finite_dl):
19691955
dl = finite_dl
@@ -1984,7 +1970,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
19841970
y0, y1 = ylocator.view_limits(y0, y1)
19851971
self.set_ybound(y0, y1)
19861972

1987-
#### Drawing
1973+
# Drawing
19881974

19891975
@allow_rasterization
19901976
def draw(self, renderer=None, inframe=False):
@@ -2056,7 +2042,7 @@ def draw(self, renderer=None, inframe=False):
20562042
# if the minimum zorder is negative, start rasterization
20572043
rasterization_zorder = self._rasterization_zorder
20582044
if (rasterization_zorder is not None and
2059-
len(dsu) > 0 and dsu[0][0] < rasterization_zorder):
2045+
len(dsu) > 0 and dsu[0][0] < rasterization_zorder):
20602046
renderer.start_rasterizing()
20612047
dsu_rasterized = [l for l in dsu if l[0] < rasterization_zorder]
20622048
dsu = [l for l in dsu if l[0] >= rasterization_zorder]
@@ -2133,7 +2119,7 @@ def redraw_in_frame(self):
21332119
def get_renderer_cache(self):
21342120
return self._cachedRenderer
21352121

2136-
#### Axes rectangle characteristics
2122+
# Axes rectangle characteristics
21372123

21382124
def get_frame_on(self):
21392125
"""
@@ -2430,7 +2416,7 @@ def set_axis_bgcolor(self, color):
24302416
self._axisbg = color
24312417
self.patch.set_facecolor(color)
24322418

2433-
### data limits, ticks, tick labels, and formatting
2419+
# data limits, ticks, tick labels, and formatting
24342420

24352421
def invert_xaxis(self):
24362422
"Invert the x-axis."
@@ -2575,7 +2561,7 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
25752561
other.set_xlim(self.viewLim.intervalx,
25762562
emit=False, auto=auto)
25772563
if (other.figure != self.figure and
2578-
other.figure.canvas is not None):
2564+
other.figure.canvas is not None):
25792565
other.figure.canvas.draw_idle()
25802566

25812567
return left, right
@@ -2910,8 +2896,8 @@ def get_yticklabels(self, minor=False, which=None):
29102896
List of :class:`~matplotlib.text.Text` instances.
29112897
"""
29122898
return cbook.silent_list('Text yticklabel',
2913-
self.yaxis.get_ticklabels(minor=minor,
2914-
which=which))
2899+
self.yaxis.get_ticklabels(minor=minor,
2900+
which=which))
29152901

29162902
@docstring.dedent_interpd
29172903
def set_yticklabels(self, labels, fontdict=None, minor=False, **kwargs):
@@ -3004,7 +2990,7 @@ def minorticks_off(self):
30042990
self.xaxis.set_minor_locator(mticker.NullLocator())
30052991
self.yaxis.set_minor_locator(mticker.NullLocator())
30062992

3007-
#### Interactive manipulation
2993+
# Interactive manipulation
30082994

30092995
def can_zoom(self):
30102996
"""

lib/matplotlib/backends/backend_pdf.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ def createType1Descriptor(self, t1font, fontfile):
769769
'FontFamily': t1font.prop['FamilyName'],
770770
'StemV': 50, # TODO
771771
# (see also revision 3874; but not all TeX distros have AFM files!)
772-
#'FontWeight': a number where 400 = Regular, 700 = Bold
772+
# 'FontWeight': a number where 400 = Regular, 700 = Bold
773773
}
774774

775775
self.writeObject(fontdescObject, descriptor)
@@ -1251,8 +1251,8 @@ def imageObject(self, image):
12511251
self.images[image] = (name, ob)
12521252
return name
12531253

1254-
## These two from backend_ps.py
1255-
## TODO: alpha (SMask, p. 518 of pdf spec)
1254+
# These two from backend_ps.py
1255+
# TODO: alpha (SMask, p. 518 of pdf spec)
12561256

12571257
def _rgb(self, im):
12581258
h, w, s = im.as_rgba_str()
@@ -1710,10 +1710,8 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans,
17101710
simplify=False):
17111711
if len(vertices):
17121712
x, y = vertices[-2:]
1713-
if (x < 0 or
1714-
y < 0 or
1715-
x > self.file.width * 72 or
1716-
y > self.file.height * 72):
1713+
if (x < 0 or y < 0 or
1714+
x > self.file.width * 72 or y > self.file.height * 72):
17171715
continue
17181716
dx, dy = x - lastx, y - lasty
17191717
output(1, 0, 0, 1, dx, dy, Op.concat_matrix,
@@ -1970,8 +1968,8 @@ def check_simple_method(s):
19701968
chunks[-1][1].append(c)
19711969
else:
19721970
chunks.append((char_type, [c]))
1973-
use_simple_method = (len(chunks) == 1
1974-
and chunks[-1][0] == 1)
1971+
use_simple_method = (len(chunks) == 1 and
1972+
chunks[-1][0] == 1)
19751973
return use_simple_method, chunks
19761974

19771975
def draw_text_simple():
@@ -2255,7 +2253,7 @@ def clip_cmd(self, cliprect, clippath):
22552253
cmds.extend(self.pop())
22562254
# Unless we hit the right one, set the clip polygon
22572255
if ((self._cliprect, self._clippath) != (cliprect, clippath) or
2258-
self.parent is None):
2256+
self.parent is None):
22592257
cmds.extend(self.push())
22602258
if self._cliprect != cliprect:
22612259
cmds.extend([cliprect, Op.rectangle, Op.clip, Op.endpath])
@@ -2417,8 +2415,8 @@ def close(self):
24172415
PDF file.
24182416
"""
24192417
self._file.close()
2420-
if (self.get_pagecount() == 0 and not self.keep_empty
2421-
and not self._file.passed_in_file_object):
2418+
if (self.get_pagecount() == 0 and not self.keep_empty and
2419+
not self._file.passed_in_file_object):
24222420
os.remove(self._file.fh.name)
24232421
self._file = None
24242422

0 commit comments

Comments
 (0)