Skip to content

Commit b52a8b1

Browse files
committed
STY: More pep8 fixes
1 parent 9b0af8a commit b52a8b1

File tree

7 files changed

+141
-170
lines changed

7 files changed

+141
-170
lines changed

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/contour.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ def clabel(self, *args, **kwargs):
205205
self.labelMappable = cm.ScalarMappable(cmap=cmap,
206206
norm=colors.NoNorm())
207207

208-
#self.labelTexts = [] # Initialized in ContourSet.__init__
209-
#self.labelCValues = [] # same
210208
self.labelXYs = []
211209

212210
if cbook.iterable(self.labelManual):
@@ -372,7 +370,7 @@ def locate_label(self, linecontour, labelwidth):
372370

373371
XX = np.resize(linecontour[:, 0], (xsize, ysize))
374372
YY = np.resize(linecontour[:, 1], (xsize, ysize))
375-
#I might have fouled up the following:
373+
# I might have fouled up the following:
376374
yfirst = YY[:, 0].reshape(xsize, 1)
377375
ylast = YY[:, -1].reshape(xsize, 1)
378376
xfirst = XX[:, 0].reshape(xsize, 1)
@@ -381,13 +379,10 @@ def locate_label(self, linecontour, labelwidth):
381379
L = np.sqrt((xlast - xfirst) ** 2 + (ylast - yfirst) ** 2).ravel()
382380
dist = np.add.reduce(([(abs(s)[i] / L[i]) for i in range(xsize)]), -1)
383381
x, y, ind = self.get_label_coords(dist, XX, YY, ysize, labelwidth)
384-
#print 'ind, x, y', ind, x, y
385382

386383
# There must be a more efficient way...
387384
lc = [tuple(l) for l in linecontour]
388385
dind = lc.index((x, y))
389-
#print 'dind', dind
390-
#dind = list(linecontour).index((x,y))
391386

392387
return x, y, dind
393388

@@ -494,7 +489,7 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
494489
# The current implementation removes contours completely
495490
# covered by labels. Uncomment line below to keep
496491
# original contour if this is the preferred behavior.
497-
#if not len(nlc): nlc = [ lc ]
492+
# if not len(nlc): nlc = [ lc ]
498493

499494
return rotation, nlc
500495

@@ -843,8 +838,8 @@ def __init__(self, ax, *args, **kwargs):
843838
self.extend = kwargs.get('extend', 'neither')
844839
self.antialiased = kwargs.get('antialiased', None)
845840
if self.antialiased is None and self.filled:
846-
self.antialiased = False # eliminate artifacts; we are not
847-
# stroking the boundaries.
841+
# eliminate artifacts; we are not stroking the boundaries
842+
self.antialiased = False
848843
# The default for line contours will be taken from
849844
# the LineCollection default, which uses the
850845
# rcParams['lines.antialiased']

0 commit comments

Comments
 (0)