Skip to content

Commit a05a02a

Browse files
committed
Merge pull request matplotlib#4081 from tacaswell/pep8_version_fix
Pep8 version fixes
2 parents e2a8342 + 99e60f3 commit a05a02a

File tree

25 files changed

+125
-160
lines changed

25 files changed

+125
-160
lines changed

doc/api/api_changes/code_removal.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Code Removal
33

44
Legend
55
------
6-
- Removed handling of `loc` as a positional argument to `Legend`
6+
Removed handling of `loc` as a positional argument to `Legend`
77

88

99
Legend handlers
@@ -78,3 +78,10 @@ Deprecated in 2009.
7878
Remove ``NavigationToolbar2QTAgg``
7979
----------------------------------
8080
Added no functionality over the base ``NavigationToolbar2Qt``
81+
82+
83+
mpl.py
84+
------
85+
86+
Remove the module `matplotlib.mpl`. Deprecated in 1.3 by
87+
PR #1670 and commit 78ce67d161625833cacff23cfe5d74920248c5b2

examples/animation/strip_chart_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import matplotlib.animation as animation
99

1010

11-
class Scope(object)
11+
class Scope(object):
1212
def __init__(self, ax, maxt=2, dt=0.02):
1313
self.ax = ax
1414
self.dt = dt

examples/axes_grid/demo_axes_grid2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def add_inner_title(ax, title, loc, size=None, **kwargs):
3737
grid = ImageGrid(F, 211, # similar to subplot(111)
3838
nrows_ncols=(1, 3),
3939
direction="row",
40-
axes_pad = 0.05,
40+
axes_pad=0.05,
4141
add_all=True,
42-
label_mode = "1",
43-
share_all = True,
42+
label_mode="1",
43+
share_all=True,
4444
cbar_location="top",
4545
cbar_mode="each",
4646
cbar_size="7%",
@@ -75,10 +75,10 @@ def add_inner_title(ax, title, loc, size=None, **kwargs):
7575
grid2 = ImageGrid(F, 212,
7676
nrows_ncols=(1, 3),
7777
direction="row",
78-
axes_pad = 0.05,
78+
axes_pad=0.05,
7979
add_all=True,
80-
label_mode = "1",
81-
share_all = True,
80+
label_mode="1",
81+
share_all=True,
8282
cbar_location="right",
8383
cbar_mode="single",
8484
cbar_size="10%",

examples/axes_grid/demo_edge_colorbar.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ def demo_bottom_cbar(fig):
1717
"""
1818
grid = AxesGrid(fig, 121, # similar to subplot(132)
1919
nrows_ncols=(2, 2),
20-
axes_pad = 0.10,
20+
axes_pad=0.10,
2121
share_all=True,
22-
label_mode = "1",
23-
cbar_location = "bottom",
22+
label_mode="1",
23+
cbar_location="bottom",
2424
cbar_mode="edge",
25-
cbar_pad = 0.25,
26-
cbar_size = "15%",
25+
cbar_pad=0.25,
26+
cbar_size="15%",
2727
direction="column"
2828
)
2929

@@ -51,9 +51,9 @@ def demo_right_cbar(fig):
5151

5252
grid = AxesGrid(F, 122, # similar to subplot(122)
5353
nrows_ncols=(2, 2),
54-
axes_pad = 0.10,
55-
label_mode = "1",
56-
share_all = True,
54+
axes_pad=0.10,
55+
label_mode="1",
56+
share_all=True,
5757
cbar_location="right",
5858
cbar_mode="edge",
5959
cbar_size="7%",

examples/event_handling/lasso_demo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def __init__(self, ax, data):
4343
self.collection = RegularPolyCollection(
4444
fig.dpi, 6, sizes=(100,),
4545
facecolors=facecolors,
46-
offsets = self.xys,
47-
transOffset = ax.transData)
46+
offsets=self.xys,
47+
transOffset=ax.transData)
4848

4949
ax.add_collection(self.collection)
5050

@@ -69,7 +69,9 @@ def onpress(self, event):
6969
return
7070
if event.inaxes is None:
7171
return
72-
self.lasso = Lasso(event.inaxes, (event.xdata, event.ydata), self.callback)
72+
self.lasso = Lasso(event.inaxes,
73+
(event.xdata, event.ydata),
74+
self.callback)
7375
# acquire a lock on the widget drawing
7476
self.canvas.widgetlock(self.lasso)
7577

examples/pylab_examples/contourf_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777

7878
CS4 = plt.contour(X, Y, Z, levels,
7979
colors=('k',),
80-
linewidths = (3,),
81-
origin = origin)
80+
linewidths=(3,),
81+
origin=origin)
8282
plt.title('Listed colors (3 masked regions)')
8383
plt.clabel(CS4, fmt='%2.1f', colors='w', fontsize=14)
8484

@@ -95,7 +95,7 @@
9595
# instead of using the "bad" colormap value for them, it draws
9696
# nothing at all in them. Therefore the following would have
9797
# no effect:
98-
#cmap.set_bad("red")
98+
# cmap.set_bad("red")
9999

100100
fig, axs = plt.subplots(2, 2)
101101
for ax, extend in zip(axs.ravel(), extends):

examples/tests/backend_driver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ def report_all_missing(directories):
342342

343343
failbackend = dict(
344344
svg=('tex_demo.py', ),
345-
agg = ('hyperlinks.py', ),
346-
pdf = ('hyperlinks.py', ),
347-
ps = ('hyperlinks.py', ),
345+
agg=('hyperlinks.py', ),
346+
pdf=('hyperlinks.py', ),
347+
ps=('hyperlinks.py', ),
348348
)
349349

350350

lib/matplotlib/__init__.py

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,26 @@
107107
import distutils.version
108108
from itertools import chain
109109

110+
import io
111+
import locale
112+
import os
113+
import re
114+
import tempfile
115+
import warnings
116+
import contextlib
117+
import distutils.sysconfig
118+
119+
# cbook must import matplotlib only within function
120+
# definitions, so it is safe to import from it here.
121+
from matplotlib.cbook import is_string_like, mplDeprecation
122+
from matplotlib.compat import subprocess
123+
from matplotlib.rcsetup import (defaultParams,
124+
validate_backend)
125+
126+
import numpy
127+
from six.moves.urllib.request import urlopen
128+
from six.moves import reload_module as reload
129+
110130
__version__ = str('1.5.dev1')
111131
__version__numpy__ = str('1.6') # minimum required numpy version
112132

@@ -164,51 +184,18 @@ def _forward_ilshift(self, other):
164184
return self
165185
pyparsing.Forward.__ilshift__ = _forward_ilshift
166186

167-
try:
168-
from urllib.request import urlopen
169-
except ImportError:
170-
from urllib2 import urlopen
171-
172-
import io
173-
import locale
174-
import os
175-
import re
176-
import tempfile
177-
import warnings
178-
import contextlib
179-
import distutils.sysconfig
180-
181-
# cbook must import matplotlib only within function
182-
# definitions, so it is safe to import from it here.
183-
from matplotlib.cbook import is_string_like, mplDeprecation
184-
from matplotlib.compat import subprocess
185-
186-
try:
187-
reload
188-
except NameError:
189-
# Python 3
190-
from imp import reload
191-
192187

193188
if not hasattr(sys, 'argv'): # for modpython
194189
sys.argv = [str('modpython')]
195190

196191

197-
from matplotlib.rcsetup import (defaultParams,
198-
validate_backend)
199-
200192
major, minor1, minor2, s, tmp = sys.version_info
201-
_python24 = (major == 2 and minor1 >= 4) or major >= 3
193+
_python26 = (major == 2 and minor1 >= 6) or major >= 3
202194

203-
# the havedate check was a legacy from old matplotlib which preceeded
204-
# datetime support
205-
_havedate = True
195+
if not _python26:
196+
raise ImportError('matplotlib requires Python 2.6 or later')
206197

207-
if not _python24:
208-
raise ImportError('matplotlib requires Python 2.4 or later')
209198

210-
211-
import numpy
212199
if not compare_versions(numpy.__version__, __version__numpy__):
213200
raise ImportError(
214201
'numpy %s or later is required; you have %s' % (
@@ -1125,7 +1112,6 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
11251112
rcParams['text.usetex'] = checkdep_usetex(rcParams['text.usetex'])
11261113

11271114
if rcParams['axes.formatter.use_locale']:
1128-
import locale
11291115
locale.setlocale(locale.LC_ALL, '')
11301116

11311117

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from numpy import ma
1212

1313
import matplotlib
14-
rcParams = matplotlib.rcParams
1514

1615
import matplotlib.cbook as cbook
1716
from matplotlib.cbook import _string_to_bool, mplDeprecation
@@ -40,6 +39,8 @@
4039
from matplotlib.axes._base import _AxesBase
4140
from matplotlib.axes._base import _process_plot_format
4241

42+
rcParams = matplotlib.rcParams
43+
4344
iterable = cbook.iterable
4445
is_string_like = cbook.is_string_like
4546
is_sequence_of_strings = cbook.is_sequence_of_strings

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from numpy import ma
1414

1515
import matplotlib
16-
rcParams = matplotlib.rcParams
1716

1817
from matplotlib import cbook
1918
from matplotlib.cbook import _string_to_bool
@@ -35,6 +34,7 @@
3534

3635
from matplotlib.cbook import iterable
3736

37+
rcParams = matplotlib.rcParams
3838

3939
is_string_like = cbook.is_string_like
4040
is_sequence_of_strings = cbook.is_sequence_of_strings

0 commit comments

Comments
 (0)