Skip to content

Commit bb1a328

Browse files
committed
Fixed failing PEP8 test.
1 parent bc3e3ed commit bb1a328

File tree

12 files changed

+79
-47
lines changed

12 files changed

+79
-47
lines changed

lib/matplotlib/cm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def __init__(self, norm=None, cmap=None):
188188
if norm is None:
189189
norm = colors.Normalize()
190190

191-
self._A = None;
191+
self._A = None
192192
#: The Normalization instance of this ScalarMappable.
193193
self.norm = norm
194194
#: The Colormap instance of this ScalarMappable.

lib/matplotlib/colorbar.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,10 @@ def _add_solids(self, X, Y, C):
501501
self.dividers.remove()
502502
self.dividers = None
503503
if self.drawedges:
504-
self.dividers = collections.LineCollection(
505-
self._edges(X, Y),
504+
linewidths = (0.5 * mpl.rcParams['axes.linewidth'],)
505+
self.dividers = collections.LineCollection(self._edges(X, Y),
506506
colors=(mpl.rcParams['axes.edgecolor'],),
507-
linewidths=(
508-
0.5 * mpl.rcParams['axes.linewidth'],)
509-
)
507+
linewidths=linewidths)
510508
self.ax.add_collection(self.dividers)
511509

512510
def add_lines(self, levels, colors, linewidths, erase=True):
@@ -725,9 +723,9 @@ def _uniform_y(self, N):
725723
y = np.linspace(0, 1, N)
726724
else:
727725
automin = automax = 1. / (N - 1.)
728-
extendlength = self._get_extension_lengths(
729-
self.extendfrac,
730-
automin, automax, default=0.05)
726+
extendlength = self._get_extension_lengths(self.extendfrac,
727+
automin, automax,
728+
default=0.05)
731729
if self.extend == 'both':
732730
y = np.zeros(N + 2, 'd')
733731
y[0] = 0. - extendlength[0]
@@ -986,19 +984,23 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
986984
'''
987985
locations = ["left", "right", "top", "bottom"]
988986
if orientation is not None and location is not None:
989-
raise TypeError('position and orientation are mutually exclusive. Consider ' \
990-
'setting the position to any of %s' % ', '.join(locations))
987+
msg = ('position and orientation are mutually exclusive. '
988+
'Consider setting the position to any of '
989+
'{0}'.format(', '.join(locations)))
990+
raise TypeError(msg)
991991

992992
# provide a default location
993993
if location is None and orientation is None:
994994
location = 'right'
995995

996-
# allow the user to not specify the location by specifying the orientation instead
996+
# allow the user to not specify the location by specifying the
997+
# orientation instead
997998
if location is None:
998999
location = 'right' if orientation == 'vertical' else 'bottom'
9991000

10001001
if location not in locations:
1001-
raise ValueError('Invalid colorbar location. Must be one of %s' % ', '.join(locations))
1002+
raise ValueError('Invalid colorbar location. Must be one '
1003+
'of %s' % ', '.join(locations))
10021004

10031005
default_location_settings = {'left': {'anchor': (1.0, 0.5),
10041006
'panchor': (0.0, 0.5),
@@ -1014,7 +1016,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
10141016
'orientation': 'horizontal'},
10151017
'bottom': {'anchor': (0.5, 1.0),
10161018
'panchor': (0.5, 0.0),
1017-
'pad': 0.15, # backwards compat
1019+
'pad': 0.15, # backwards compat
10181020
'orientation': 'horizontal'},
10191021
}
10201022

@@ -1029,19 +1031,18 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
10291031
parent_anchor = kw.pop('panchor', loc_settings['panchor'])
10301032
pad = kw.pop('pad', loc_settings['pad'])
10311033

1032-
10331034
# turn parents into a list if it is not already
10341035
if not isinstance(parents, (list, tuple)):
10351036
parents = [parents]
10361037

10371038
fig = parents[0].get_figure()
10381039
if not all(fig is ax.get_figure() for ax in parents):
1039-
raise ValueError('Unable to create a colorbar axes as not all ' + \
1040+
raise ValueError('Unable to create a colorbar axes as not all '
10401041
'parents share the same figure.')
10411042

10421043
# take a bounding box around all of the given axes
1043-
parents_bbox = mtrans.Bbox.union([ax.get_position(original=True).frozen() \
1044-
for ax in parents])
1044+
parents_bbox = mtrans.Bbox.union([ax.get_position(original=True).frozen()
1045+
for ax in parents])
10451046

10461047
pb = parents_bbox
10471048
if location in ('left', 'right'):
@@ -1054,11 +1055,11 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
10541055
if location == 'bottom':
10551056
pbcb, _, pb1 = pb.splity(fraction, fraction + pad)
10561057
else:
1057-
pb1, _, pbcb = pb.splity(1 - fraction - pad, 1 - fraction)
1058+
pb1, _, pbcb = pb.splity(1 - fraction - pad, 1 - fraction)
10581059
pbcb = pbcb.shrunk(shrink, 1.0).anchored(anchor, pbcb)
10591060

10601061
# define the aspect ratio in terms of y's per x rather than x's per y
1061-
aspect = 1.0/aspect
1062+
aspect = 1.0 / aspect
10621063

10631064
# define a transform which takes us from old axes coordinates to
10641065
# new axes coordinates

lib/matplotlib/lines.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,13 @@ def draw(self, renderer):
613613
if self.get_path_effects():
614614
affine_frozen = affine.frozen()
615615
for pe in self.get_path_effects():
616-
pe.draw_markers(renderer, gc, marker_path, marker_trans,
617-
subsampled, affine_frozen, rgbaFace)
616+
pe.draw_markers(renderer, gc, marker_path,
617+
marker_trans, subsampled,
618+
affine_frozen, rgbaFace)
618619
else:
619-
renderer.draw_markers(
620-
gc, marker_path, marker_trans, subsampled, affine.frozen(),
621-
rgbaFace)
620+
renderer.draw_markers(gc, marker_path, marker_trans,
621+
subsampled, affine.frozen(),
622+
rgbaFace)
622623

623624
alt_marker_path = marker.get_alt_path()
624625
if alt_marker_path:

lib/matplotlib/scale.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ def inverted(self):
359359
return InvertedSymmetricalLogTransform(self.base, self.linthresh,
360360
self.linscale)
361361

362+
362363
class InvertedSymmetricalLogTransform(Transform):
363364
input_dims = 1
364365
output_dims = 1

lib/matplotlib/tests/test_coding_standards.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class StandardReportWithExclusions(pep8.StandardReport):
2323
'*/matplotlib/bezier.py',
2424
'*/matplotlib/cbook.py',
2525
'*/matplotlib/collections.py',
26-
'*/matplotlib/dates.py',
2726
'*/matplotlib/docstring.py',
2827
'*/matplotlib/dviread.py',
2928
'*/matplotlib/finance.py',
@@ -44,7 +43,6 @@ class StandardReportWithExclusions(pep8.StandardReport):
4443
'*/matplotlib/stackplot.py',
4544
'*/matplotlib/texmanager.py',
4645
'*/matplotlib/text.py',
47-
'*/matplotlib/ticker.py',
4846
'*/matplotlib/transforms.py',
4947
'*/matplotlib/type1font.py',
5048
'*/matplotlib/widgets.py',
@@ -96,11 +94,9 @@ class StandardReportWithExclusions(pep8.StandardReport):
9694
'*/matplotlib/tests/test_streamplot.py',
9795
'*/matplotlib/tests/test_subplots.py',
9896
'*/matplotlib/tests/test_text.py',
99-
'*/matplotlib/tests/test_ticker.py',
10097
'*/matplotlib/tests/test_tightlayout.py',
10198
'*/matplotlib/tests/test_transforms.py',
10299
'*/matplotlib/tests/test_triangulation.py',
103-
'*/matplotlib/tests/test_ttconv.py',
104100
'*/matplotlib/compat/subprocess.py',
105101
'*/matplotlib/backends/__init__.py',
106102
'*/matplotlib/backends/backend_agg.py',
@@ -144,7 +140,7 @@ class StandardReportWithExclusions(pep8.StandardReport):
144140
'*/matplotlib/projections/geo.py',
145141
'*/matplotlib/projections/polar.py']
146142

147-
#; A class attribute to store patterns which have seen exceptions.
143+
#: A class attribute to store patterns which have seen exceptions.
148144
matched_exclusions = set()
149145

150146
def get_file_results(self):
@@ -192,6 +188,22 @@ def test_pep8_conformance():
192188
'E123', 'E124', 'E125', 'E126', 'E127',
193189
'E128')
194190

191+
# Support for egg shared object wrappers, which are not PEP8 compliant,
192+
# nor part of the matplotlib repository.
193+
# DO NOT ADD FILES *IN* THE REPOSITORY TO THIS LIST.
194+
pep8style.options.exclude.extend(
195+
['_delaunay.py',
196+
'_image.py',
197+
'_tri.py',
198+
'_backend_agg.py',
199+
'_tkagg.py',
200+
'ft2font.py',
201+
'_cntr.py',
202+
'_png.py',
203+
'_path.py',
204+
'ttconv.py',
205+
'pyparsing*'])
206+
195207
# Allow users to add their own exclude list.
196208
extra_exclude_file = os.path.join(os.path.dirname(__file__),
197209
'.pep8_test_exclude.txt')

lib/matplotlib/tests/test_figure.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def test_suptitle():
7878
# only test png and svg. The PDF output appears correct,
7979
# but Ghostscript does not preserve the background color.
8080
extensions=['png', 'svg'],
81-
savefig_kwarg={'facecolor': (0, 1, 0.4), 'edgecolor': 'none'})
81+
savefig_kwarg={'facecolor': (0, 1, 0.4),
82+
'edgecolor': 'none'})
8283
def test_alpha():
8384
# We want an image which has a background color and an
8485
# alpha of 0.4.
@@ -92,6 +93,7 @@ def test_alpha():
9293
alpha=0.6,
9394
facecolor='red'))
9495

96+
9597
@cleanup
9698
def test_too_many_figures():
9799
import warnings

lib/matplotlib/tests/test_path.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
from matplotlib.path import Path
22
from nose.tools import assert_raises
33

4+
45
def test_readonly_path():
56
path = Path.unit_circle()
67

78
def modify_vertices():
89
path.vertices = path.vertices * 2.0
910

1011
assert_raises(AttributeError, modify_vertices)
12+
13+
14+
if __name__ == '__main__':
15+
import nose
16+
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_patheffects.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@image_comparison(baseline_images=['patheffect1'], remove_text=True)
1010
def test_patheffect1():
1111
ax1 = plt.subplot(111)
12-
ax1.imshow([[1,2],[2,3]])
12+
ax1.imshow([[1, 2], [2, 3]])
1313
txt = ax1.annotate("test", (1., 1.), (0., 0),
1414
arrowprops=dict(arrowstyle="->",
1515
connectionstyle="angle3", lw=2),
@@ -31,14 +31,13 @@ def test_patheffect1():
3131
def test_patheffect2():
3232

3333
ax2 = plt.subplot(111)
34-
arr = np.arange(25).reshape((5,5))
34+
arr = np.arange(25).reshape((5, 5))
3535
ax2.imshow(arr)
3636
cntr = ax2.contour(arr, colors="k")
3737

3838
plt.setp(cntr.collections,
3939
path_effects=[withStroke(linewidth=3, foreground="w")])
4040

41-
4241
clbls = ax2.clabel(cntr, fmt="%2.0f", use_clabeltext=True)
4342
plt.setp(clbls,
4443
path_effects=[withStroke(linewidth=3, foreground="w")])
@@ -51,3 +50,8 @@ def test_patheffect3():
5150
p1, = ax3.plot([0, 1], [0, 1])
5251
leg = ax3.legend([p1], ["Line 1"], fancybox=True, loc=2)
5352
leg.legendPatch.set_path_effects([withSimplePatchShadow()])
53+
54+
55+
if __name__ == '__main__':
56+
import nose
57+
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_ticker.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def test_LinearLocator():
2626

2727
def test_MultipleLocator():
2828
loc = mticker.MultipleLocator(base=3.147)
29-
test_value = np.array([-9.441, -6.294, -3.147, 0., 3.147, 6.294, 9.441, 12.588])
29+
test_value = np.array([-9.441, -6.294, -3.147, 0., 3.147, 6.294,
30+
9.441, 12.588])
3031
assert_almost_equal(loc.tick_values(-7, 10), test_value)
3132

3233

@@ -35,8 +36,9 @@ def test_LogLocator():
3536

3637
assert_raises(ValueError, loc.tick_values, 0, 1000)
3738

38-
test_value = np.array([1.00000000e-05, 1.00000000e-03, 1.00000000e-01, 1.00000000e+01,
39-
1.00000000e+03, 1.00000000e+05, 1.00000000e+07, 1.000000000e+09])
39+
test_value = np.array([1.00000000e-05, 1.00000000e-03, 1.00000000e-01,
40+
1.00000000e+01, 1.00000000e+03, 1.00000000e+05,
41+
1.00000000e+07, 1.000000000e+09])
4042
assert_almost_equal(loc.tick_values(0.001, 1.1e5), test_value)
4143

4244
loc = mticker.LogLocator(base=2)

lib/matplotlib/tests/test_ttconv.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import matplotlib.pyplot as plt
55
import os.path
66

7+
78
@image_comparison(baseline_images=["truetype-conversion"],
89
extensions=["pdf"])
910
def test_truetype_conversion():

0 commit comments

Comments
 (0)