Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various pep8 fixes - specifically targeting files which are failing travis pep8 tests #4155

Merged
merged 5 commits into from Feb 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions examples/pylab_examples/demo_annotation_box.py
Expand Up @@ -43,7 +43,6 @@
boxcoords=("axes fraction", "data"),
box_alignment=(0., 0.5),
arrowprops=dict(arrowstyle="->"))
#arrowprops=None)

ax.add_artist(ab)

Expand All @@ -56,7 +55,6 @@
boxcoords="offset points",
pad=0.3,
arrowprops=dict(arrowstyle="->"))
#arrowprops=None)

ax.add_artist(ab)

Expand Down
28 changes: 14 additions & 14 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -2807,7 +2807,7 @@ def xywhere(xs, ys, mask):

if yerr is not None:
if (iterable(yerr) and len(yerr) == 2 and
iterable(yerr[0]) and iterable(yerr[1])):
iterable(yerr[0]) and iterable(yerr[1])):
# using list comps rather than arrays to preserve units
lower = [thisy - thiserr for (thisy, thiserr)
in cbook.safezip(y, yerr[0])]
Expand Down Expand Up @@ -3066,8 +3066,7 @@ def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,
# compatibility
if sym == '':
# blow away existing dict and make one for invisible markers
flierprops = dict(linestyle='none', marker='',
color='none')
flierprops = dict(linestyle='none', marker='', color='none')
# turn the fliers off just to be safe
showfliers = False
# now process the symbol string
Expand All @@ -3088,7 +3087,7 @@ def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,
# replace medians if necessary:
if usermedians is not None:
if (len(np.ravel(usermedians)) != len(bxpstats) or
np.shape(usermedians)[0] != len(bxpstats)):
np.shape(usermedians)[0] != len(bxpstats)):
medmsg = 'usermedians length not compatible with x'
raise ValueError(medmsg)
else:
Expand Down Expand Up @@ -4680,8 +4679,8 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
aspect = rcParams['image.aspect']
self.set_aspect(aspect)
im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,
filternorm=filternorm,
filterrad=filterrad, resample=resample, **kwargs)
filternorm=filternorm, filterrad=filterrad,
resample=resample, **kwargs)

im.set_data(X)
im.set_alpha(alpha)
Expand Down Expand Up @@ -4966,7 +4965,7 @@ def pcolor(self, *args, **kwargs):
X3[:, newaxis], Y3[:, newaxis],
X4[:, newaxis], Y4[:, newaxis],
X1[:, newaxis], Y1[:, newaxis]),
axis=1)
axis=1)
verts = xy.reshape((npoly, 5, 2))

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

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

# Transform from native to data coordinates?
t = collection._transform
if (not isinstance(t, mtransforms.Transform)
and hasattr(t, '_as_mpl_transform')):
if (not isinstance(t, mtransforms.Transform) and
hasattr(t, '_as_mpl_transform')):
t = t._as_mpl_transform(self.axes)

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

# Transform from native to data coordinates?
t = collection._transform
if (not isinstance(t, mtransforms.Transform)
and hasattr(t, '_as_mpl_transform')):
if (not isinstance(t, mtransforms.Transform) and
hasattr(t, '_as_mpl_transform')):
t = t._as_mpl_transform(self.axes)

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

# convert to one dimensional arrays
# This should also be moved to the QuadMesh class
C = ma.ravel(C) # data point in each cell is value
# at lower left corner

# data point in each cell is value at lower left corner
C = ma.ravel(C)
X = x.ravel()
Y = y.ravel()
Nx = nc + 1
Expand Down
62 changes: 24 additions & 38 deletions lib/matplotlib/axes/_base.py
Expand Up @@ -906,8 +906,10 @@ def cla(self):
self.containers = []

self.grid(self._gridOn, which=rcParams['axes.grid.which'])
props = font_manager.FontProperties(size=rcParams['axes.titlesize'],
weight=rcParams['axes.titleweight'])
props = font_manager.FontProperties(
size=rcParams['axes.titlesize'],
weight=rcParams['axes.titleweight']
)

self.titleOffsetTrans = mtransforms.ScaledTranslation(
0.0, 5.0 / 72.0, self.figure.dpi_scale_trans)
Expand Down Expand Up @@ -1179,7 +1181,7 @@ def apply_aspect(self, position=None):
else:
A = aspect

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

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

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

changex = (self in self._shared_y_axes
and self not in self._shared_x_axes)
changey = (self in self._shared_x_axes
and self not in self._shared_y_axes)
changex = (self in self._shared_y_axes and
self not in self._shared_x_axes)
changey = (self in self._shared_x_axes and
self not in self._shared_y_axes)
if changex and changey:
warnings.warn("adjustable='datalim' cannot work with shared "
"x and y axes")
return
if changex:
adjust_y = False
else:
#print 'xmarg, ymarg, Xmarg, Ymarg', xmarg, ymarg, Xmarg, Ymarg
if xmarg > xm and ymarg > ym:
adjy = ((Ymarg > 0 and y_expander < 0)
or (Xmarg < 0 and y_expander > 0))
adjy = ((Ymarg > 0 and y_expander < 0) or
(Xmarg < 0 and y_expander > 0))
else:
adjy = y_expander > 0
#print 'y_expander, adjy', y_expander, adjy
adjust_y = changey or adjy # (Ymarg > xmarg)
if adjust_y:
yc = 0.5 * (ymin + ymax)
Expand All @@ -1274,8 +1269,6 @@ def apply_aspect(self, position=None):
self.set_ybound((10. ** y0, 10. ** y1))
else:
self.set_ybound((y0, y1))
#print 'New y0, y1:', y0, y1
#print 'New ysize, ysize/xsize', y1-y0, (y1-y0)/xsize
else:
xc = 0.5 * (xmin + xmax)
x0 = xc - Xsize / 2.0
Expand All @@ -1284,8 +1277,6 @@ def apply_aspect(self, position=None):
self.set_xbound((10. ** x0, 10. ** x1))
else:
self.set_xbound((x0, x1))
#print 'New x0, x1:', x0, x1
#print 'New xsize, ysize/xsize', x1-x0, ysize/(x1-x0)

def axis(self, *v, **kwargs):
"""
Expand Down Expand Up @@ -1402,7 +1393,7 @@ def get_yticklines(self):
return cbook.silent_list('Line2D ytickline',
self.yaxis.get_ticklines())

#### Adding and tracking artists
# Adding and tracking artists

def _sci(self, im):
"""
Expand Down Expand Up @@ -1588,7 +1579,7 @@ def _update_patch_limits(self, patch):
xys = patch.get_patch_transform().transform(vertices)
if patch.get_data_transform() != self.transData:
patch_to_data = (patch.get_data_transform() -
self.transData)
self.transData)
xys = patch_to_data.transform(xys)

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

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

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

# process kwargs 2nd since these will override default units
if kwargs is not None:
xunits = kwargs.pop('xunits', self.xaxis.units)
if self.name == 'polar':
xunits = kwargs.pop('thetaunits', xunits)
if xunits != self.xaxis.units:
#print '\tkw setting xunits', xunits
self.xaxis.set_units(xunits)
# If the units being set imply a different converter,
# we need to update.
Expand All @@ -1719,7 +1706,6 @@ def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):
if self.name == 'polar':
yunits = kwargs.pop('runits', yunits)
if yunits != self.yaxis.units:
#print '\tkw setting yunits', yunits
self.yaxis.set_units(yunits)
# If the units being set imply a different converter,
# we need to update.
Expand Down Expand Up @@ -1937,7 +1923,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
if scalex and self._autoscaleXon:
xshared = self._shared_x_axes.get_siblings(self)
dl = [ax.dataLim for ax in xshared]
#ignore non-finite data limits if good limits exist
# ignore non-finite data limits if good limits exist
finite_dl = [d for d in dl if np.isfinite(d).all()]
if len(finite_dl):
dl = finite_dl
Expand All @@ -1963,7 +1949,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
if scaley and self._autoscaleYon:
yshared = self._shared_y_axes.get_siblings(self)
dl = [ax.dataLim for ax in yshared]
#ignore non-finite data limits if good limits exist
# ignore non-finite data limits if good limits exist
finite_dl = [d for d in dl if np.isfinite(d).all()]
if len(finite_dl):
dl = finite_dl
Expand All @@ -1984,7 +1970,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
y0, y1 = ylocator.view_limits(y0, y1)
self.set_ybound(y0, y1)

#### Drawing
# Drawing

@allow_rasterization
def draw(self, renderer=None, inframe=False):
Expand Down Expand Up @@ -2056,7 +2042,7 @@ def draw(self, renderer=None, inframe=False):
# if the minimum zorder is negative, start rasterization
rasterization_zorder = self._rasterization_zorder
if (rasterization_zorder is not None and
len(dsu) > 0 and dsu[0][0] < rasterization_zorder):
len(dsu) > 0 and dsu[0][0] < rasterization_zorder):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a bunch of changes like this--did PEP8 change its mind? I was fairly sure that the original version was what it wanted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was me just going through pep8. I believe it may have been disabled already on travis side.

renderer.start_rasterizing()
dsu_rasterized = [l for l in dsu if l[0] < rasterization_zorder]
dsu = [l for l in dsu if l[0] >= rasterization_zorder]
Expand Down Expand Up @@ -2133,7 +2119,7 @@ def redraw_in_frame(self):
def get_renderer_cache(self):
return self._cachedRenderer

#### Axes rectangle characteristics
# Axes rectangle characteristics

def get_frame_on(self):
"""
Expand Down Expand Up @@ -2430,7 +2416,7 @@ def set_axis_bgcolor(self, color):
self._axisbg = color
self.patch.set_facecolor(color)

### data limits, ticks, tick labels, and formatting
# data limits, ticks, tick labels, and formatting

def invert_xaxis(self):
"Invert the x-axis."
Expand Down Expand Up @@ -2575,7 +2561,7 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
other.set_xlim(self.viewLim.intervalx,
emit=False, auto=auto)
if (other.figure != self.figure and
other.figure.canvas is not None):
other.figure.canvas is not None):
other.figure.canvas.draw_idle()

return left, right
Expand Down Expand Up @@ -2910,8 +2896,8 @@ def get_yticklabels(self, minor=False, which=None):
List of :class:`~matplotlib.text.Text` instances.
"""
return cbook.silent_list('Text yticklabel',
self.yaxis.get_ticklabels(minor=minor,
which=which))
self.yaxis.get_ticklabels(minor=minor,
which=which))

@docstring.dedent_interpd
def set_yticklabels(self, labels, fontdict=None, minor=False, **kwargs):
Expand Down Expand Up @@ -3004,7 +2990,7 @@ def minorticks_off(self):
self.xaxis.set_minor_locator(mticker.NullLocator())
self.yaxis.set_minor_locator(mticker.NullLocator())

#### Interactive manipulation
# Interactive manipulation

def can_zoom(self):
"""
Expand Down
22 changes: 10 additions & 12 deletions lib/matplotlib/backends/backend_pdf.py
Expand Up @@ -769,7 +769,7 @@ def createType1Descriptor(self, t1font, fontfile):
'FontFamily': t1font.prop['FamilyName'],
'StemV': 50, # TODO
# (see also revision 3874; but not all TeX distros have AFM files!)
#'FontWeight': a number where 400 = Regular, 700 = Bold
# 'FontWeight': a number where 400 = Regular, 700 = Bold
}

self.writeObject(fontdescObject, descriptor)
Expand Down Expand Up @@ -1251,8 +1251,8 @@ def imageObject(self, image):
self.images[image] = (name, ob)
return name

## These two from backend_ps.py
## TODO: alpha (SMask, p. 518 of pdf spec)
# These two from backend_ps.py
# TODO: alpha (SMask, p. 518 of pdf spec)

def _rgb(self, im):
h, w, s = im.as_rgba_str()
Expand Down Expand Up @@ -1710,10 +1710,8 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans,
simplify=False):
if len(vertices):
x, y = vertices[-2:]
if (x < 0 or
y < 0 or
x > self.file.width * 72 or
y > self.file.height * 72):
if (x < 0 or y < 0 or
x > self.file.width * 72 or y > self.file.height * 72):
continue
dx, dy = x - lastx, y - lasty
output(1, 0, 0, 1, dx, dy, Op.concat_matrix,
Expand Down Expand Up @@ -1970,8 +1968,8 @@ def check_simple_method(s):
chunks[-1][1].append(c)
else:
chunks.append((char_type, [c]))
use_simple_method = (len(chunks) == 1
and chunks[-1][0] == 1)
use_simple_method = (len(chunks) == 1 and
chunks[-1][0] == 1)
return use_simple_method, chunks

def draw_text_simple():
Expand Down Expand Up @@ -2255,7 +2253,7 @@ def clip_cmd(self, cliprect, clippath):
cmds.extend(self.pop())
# Unless we hit the right one, set the clip polygon
if ((self._cliprect, self._clippath) != (cliprect, clippath) or
self.parent is None):
self.parent is None):
cmds.extend(self.push())
if self._cliprect != cliprect:
cmds.extend([cliprect, Op.rectangle, Op.clip, Op.endpath])
Expand Down Expand Up @@ -2417,8 +2415,8 @@ def close(self):
PDF file.
"""
self._file.close()
if (self.get_pagecount() == 0 and not self.keep_empty
and not self._file.passed_in_file_object):
if (self.get_pagecount() == 0 and not self.keep_empty and
not self._file.passed_in_file_object):
os.remove(self._file.fh.name)
self._file = None

Expand Down