Skip to content

Commit

Permalink
Merge pull request #2491 from pelson/pep8_re-enable
Browse files Browse the repository at this point in the history
Re-enabled PEP8 test, closing #2443.
  • Loading branch information
NelleV committed Oct 9, 2013
2 parents ba49375 + 1dc0404 commit 26498aa
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 45 deletions.
18 changes: 10 additions & 8 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -558,17 +558,18 @@ def annotate(self, *args, **kwargs):
"figure points", "figure pixels", "figure fraction", "axes
points", .... See `matplotlib.text.Annotation` for more details.
textcoords : string, optional, default: None
textcoords : string, optional
string that indicates what type of coordinates `text` is. Examples:
"figure points", "figure pixels", "figure fraction", "axes
points", .... See `matplotlib.text.Annotation` for more details.
Default is None.
arrowprops : `matplotlib.lines.Line2D` properties, optional, default: None
arrowprops : `matplotlib.lines.Line2D` properties, optional
Dictionnary of line properties for the arrow that connects the
annotation to the point. If the dictionnary has a key
`arrowstyle`, a `FancyArrowPatch` instance is created and drawn.
See `matplotlib.text.Annotation` for more details on valid
options.
options. Default is None.
Returns
-------
Expand Down Expand Up @@ -3643,7 +3644,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
# Transform accum if needed
if bins == 'log':
accum = np.log10(accum + 1)
elif bins != None:
elif bins is not None:
if not iterable(bins):
minimum, maximum = min(accum), max(accum)
bins -= 1 # one less edge than bins
Expand Down Expand Up @@ -5119,7 +5120,8 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
Returns
-------
tuple : (n, bins, patches) or ([n0, n1, ...], bins, [patches0, patches1,...])
tuple : ``(n, bins, patches)`` or \
``([n0, n1, ...], bins, [patches0, patches1,...])``
Other Parameters
----------------
Expand Down Expand Up @@ -5246,7 +5248,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
# this will automatically overwrite bins,
# so that each histogram uses the same bins
m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
m = m.astype(float) # causes problems later if it's an int
m = m.astype(float) # causes problems later if it's an int
if mlast is None:
mlast = np.zeros(len(bins)-1, m.dtype)
if normed and not stacked:
Expand Down Expand Up @@ -5417,15 +5419,15 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
xmin0 = max(_saved_bounds[0]*0.9, minimum)
xmax = self.dataLim.intervalx[1]
for m in n:
xmin = np.amin(m[m != 0]) # filter out the 0 height bins
xmin = np.amin(m[m != 0]) # filter out the 0 height bins
xmin = max(xmin*0.9, minimum)
xmin = min(xmin0, xmin)
self.dataLim.intervalx = (xmin, xmax)
elif orientation == 'vertical':
ymin0 = max(_saved_bounds[1]*0.9, minimum)
ymax = self.dataLim.intervaly[1]
for m in n:
ymin = np.amin(m[m != 0]) # filter out the 0 height bins
ymin = np.amin(m[m != 0]) # filter out the 0 height bins
ymin = max(ymin*0.9, minimum)
ymin = min(ymin0, ymin)
self.dataLim.intervaly = (ymin, ymax)
Expand Down
17 changes: 9 additions & 8 deletions lib/matplotlib/axes/_base.py
Expand Up @@ -698,8 +698,6 @@ def get_yaxis_text2_transform(self, pad_points):
self.figure.dpi_scale_trans),
"center", "left")



def _update_transScale(self):
self.transScale.set(
mtransforms.blended_transform_factory(
Expand Down Expand Up @@ -1090,7 +1088,8 @@ def set_anchor(self, anchor):
===== ============
"""
if anchor in list(six.iterkeys(mtransforms.Bbox.coefs)) or len(anchor) == 2:
if (anchor in list(six.iterkeys(mtransforms.Bbox.coefs)) or
len(anchor) == 2):
self._anchor = anchor
else:
raise ValueError('argument must be among %s' %
Expand Down Expand Up @@ -1593,9 +1592,9 @@ def add_container(self, container):

def relim(self, visible_only=False):
"""
Recompute the data limits based on current artists. If you want to exclude
invisible artists from the calculation, set
`visible_only=True`
Recompute the data limits based on current artists. If you want to
exclude invisible artists from the calculation, set
``visible_only=True``
At present, :class:`~matplotlib.collections.Collection`
instances are not supported.
Expand Down Expand Up @@ -2503,7 +2502,8 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
if 'xmax' in kw:
right = kw.pop('xmax')
if kw:
raise ValueError("unrecognized kwargs: %s" % list(six.iterkeys(kw)))
raise ValueError("unrecognized kwargs: %s" %
list(six.iterkeys(kw)))

if right is None and iterable(left):
left, right = left
Expand Down Expand Up @@ -2732,7 +2732,8 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw):
if 'ymax' in kw:
top = kw.pop('ymax')
if kw:
raise ValueError("unrecognized kwargs: %s" % list(six.iterkeys(kw)))
raise ValueError("unrecognized kwargs: %s" %
list(six.iterkeys(kw)))

if top is None and iterable(bottom):
bottom, top = bottom
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/backends/backend_qt4.py
Expand Up @@ -272,7 +272,7 @@ def mouseDoubleClickEvent(self, event):
FigureCanvasBase.button_press_event(self, x, y,
button, dblclick=True)
if DEBUG:
print ('button doubleclicked:', event.button())
print('button doubleclicked:', event.button())

def mouseMoveEvent(self, event):
x = event.x()
Expand Down Expand Up @@ -720,8 +720,8 @@ def save_figure(self, *args):
matplotlib.rcParams['savefig.directory'] = startpath
else:
# save dir for next time
matplotlib.rcParams['savefig.directory'] = os.path.dirname(
six.text_type(fname))
savefig_dir = os.path.dirname(six.text_type(fname))
matplotlib.rcParams['savefig.directory'] = savefig_dir
try:
self.canvas.print_figure(six.text_type(fname))
except Exception as e:
Expand Down
8 changes: 5 additions & 3 deletions lib/matplotlib/backends/backend_webagg_core.py
Expand Up @@ -10,7 +10,8 @@
# - `backend_webagg.py` contains a concrete implementation of a basic
# application, implemented with tornado.

from __future__ import absolute_import, division, print_function, unicode_literals
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

Expand Down Expand Up @@ -283,8 +284,9 @@ def get_javascript(cls, stream=None):
json.dumps(toolitems)))

extensions = []
for filetype, ext in sorted(
FigureCanvasWebAggCore.get_supported_filetypes_grouped().items()):
for filetype, ext in sorted(FigureCanvasWebAggCore.
get_supported_filetypes_grouped().
items()):
extensions.append(ext[0])
output.write("mpl.extensions = {0};\n\n".format(
json.dumps(extensions)))
Expand Down
5 changes: 1 addition & 4 deletions lib/matplotlib/cm.py
Expand Up @@ -75,11 +75,8 @@ def _generate_cmap(name, lutsize):

LUTSIZE = mpl.rcParams['image.lut']

_cmapnames = list(six.iterkeys(datad)) # need this list because datad is changed in loop

# Generate the reversed specifications ...

for cmapname in _cmapnames:
for cmapname in list(six.iterkeys(datad)):
spec = datad[cmapname]
spec_reversed = _reverse_cmap_spec(spec)
datad[cmapname + '_r'] = spec_reversed
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/dates.py
Expand Up @@ -820,8 +820,8 @@ def __init__(self, tz=None, minticks=5, maxticks=None,
5000, 10000, 20000, 50000, 100000, 200000, 500000,
1000000]}
self._byranges = [None, list(xrange(1, 13)), list(xrange(1, 32)),
list(xrange(0, 24)), list(xrange(0, 60)), list(xrange(0, 60)),
None]
list(xrange(0, 24)), list(xrange(0, 60)),
list(xrange(0, 60)), None]

def __call__(self):
'Return the locations of the ticks'
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/figure.py
Expand Up @@ -1415,7 +1415,8 @@ def savefig(self, *args, **kwargs):

kwargs.setdefault('dpi', rcParams['savefig.dpi'])
frameon = kwargs.pop('frameon', rcParams['savefig.frameon'])
transparent = kwargs.pop('transparent', rcParams['savefig.transparent'])
transparent = kwargs.pop('transparent',
rcParams['savefig.transparent'])

if transparent:
kwargs.setdefault('facecolor', 'none')
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/__init__.py
Expand Up @@ -39,7 +39,7 @@ def setup():
"Could not set locale to English/United States. "
"Some date-related tests may fail")

use('Agg', warn=False) # use Agg backend for these tests
use('Agg', warn=False) # use Agg backend for these tests

# These settings *must* be hardcoded for running the comparison
# tests and are not necessarily the default values as specified in
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/tests/test_backend_pdf.py
Expand Up @@ -12,10 +12,12 @@

from matplotlib import cm, rcParams
from matplotlib import pyplot as plt
from matplotlib.testing.decorators import image_comparison, knownfailureif, cleanup
from matplotlib.testing.decorators import (image_comparison, knownfailureif,
cleanup)

if 'TRAVIS' not in os.environ:
@image_comparison(baseline_images=['pdf_use14corefonts'], extensions=['pdf'])
@image_comparison(baseline_images=['pdf_use14corefonts'],
extensions=['pdf'])
def test_use14corefonts():
rcParams['pdf.use14corefonts'] = True
rcParams['font.family'] = 'sans-serif'
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/tests/test_backend_pgf.py
Expand Up @@ -74,7 +74,8 @@ def create_figure():
plt.figure()
x = np.linspace(0, 1, 15)
plt.plot(x, x ** 2, "b-")
plt.fill_between([0., .4], [.4, 0.], hatch='//', facecolor="lightgray", edgecolor="red")
plt.fill_between([0., .4], [.4, 0.], hatch='//', facecolor="lightgray",
edgecolor="red")
plt.plot(x, 1 - x**2, "g>")
plt.plot([0.9], [0.5], "ro", markersize=3)
plt.text(0.9, 0.5, 'unicode (ü, °, µ) and math ($\\mu_i = x_i^2$)',
Expand Down
13 changes: 2 additions & 11 deletions lib/matplotlib/tests/test_coding_standards.py
Expand Up @@ -43,15 +43,12 @@
'*/matplotlib/_pylab_helpers.py',
'*/matplotlib/afm.py',
'*/matplotlib/artist.py',
'*/matplotlib/axes.py',
'*/matplotlib/axis.py',
'*/matplotlib/backend_bases.py',
'*/matplotlib/bezier.py',
'*/matplotlib/cbook.py',
'*/matplotlib/collections.py',
'*/matplotlib/docstring.py',
'*/matplotlib/dviread.py',
'*/matplotlib/finance.py',
'*/matplotlib/font_manager.py',
'*/matplotlib/fontconfig_pattern.py',
'*/matplotlib/gridspec.py',
Expand Down Expand Up @@ -82,10 +79,7 @@
'*/matplotlib/testing/jpl_units/UnitDblConverter.py',
'*/matplotlib/testing/jpl_units/UnitDblFormatter.py',
'*/matplotlib/testing/jpl_units/__init__.py',
'*/matplotlib/tri/tricontour.py',
'*/matplotlib/tri/triinterpolate.py',
'*/matplotlib/tri/tripcolor.py',
'*/matplotlib/tri/triplot.py',
'*/matplotlib/tests/test_axes.py',
'*/matplotlib/tests/test_bbox_tight.py',
'*/matplotlib/tests/test_dates.py',
Expand Down Expand Up @@ -123,15 +117,13 @@
'*/matplotlib/backends/backend_svg.py',
'*/matplotlib/backends/backend_template.py',
'*/matplotlib/backends/backend_tkagg.py',
'*/matplotlib/backends/backend_webagg.py',
'*/matplotlib/backends/backend_wx.py',
'*/matplotlib/backends/backend_wxagg.py',
'*/matplotlib/backends/qt4_compat.py',
'*/matplotlib/backends/tkagg.py',
'*/matplotlib/backends/windowing.py',
'*/matplotlib/backends/qt4_editor/figureoptions.py',
'*/matplotlib/backends/qt4_editor/formlayout.py',
'*/matplotlib/sphinxext/__init__.py',
'*/matplotlib/sphinxext/ipython_console_highlighting.py',
'*/matplotlib/sphinxext/ipython_directive.py',
'*/matplotlib/sphinxext/mathmpl.py',
Expand Down Expand Up @@ -246,9 +238,8 @@ def assert_pep8_conformance(module=matplotlib, exclude_files=EXCLUDE_FILES,
'{}'.format('\n '.join(unexpectedly_good)))


## Temporarily disabling test
#def test_pep8_conformance():
# assert_pep8_conformance()
def test_pep8_conformance():
assert_pep8_conformance()


if __name__ == '__main__':
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/tests/test_mlab.py
Expand Up @@ -75,7 +75,8 @@ def test_recarray_csv_roundtrip(self):
np.testing.assert_allclose(expected['t'], actual['t'])

def test_rec2csv_bad_shape_ValueError(self):
bad = np.recarray((99, 4), [(str('x'), np.float), (str('y'), np.float)])
bad = np.recarray((99, 4), [(str('x'), np.float),
(str('y'), np.float)])

# the bad recarray should trigger a ValueError for having ndim > 1.
self.assertRaises(ValueError, mlab.rec2csv, bad, self.fd)
Expand Down

0 comments on commit 26498aa

Please sign in to comment.