Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4833c88

Browse files
authored
Merge pull request #11870 from anntzer/morestyle
More style fixes.
2 parents 3a40f64 + 9686acc commit 4833c88

File tree

5 files changed

+40
-35
lines changed

5 files changed

+40
-35
lines changed

.flake8

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,12 @@ per-file-ignores =
4040
matplotlib/backends/tkagg.py: E231, E302, E701
4141
matplotlib/font_manager.py: E203, E221, E251, E261, E262, E302, E501
4242
matplotlib/fontconfig_pattern.py: E201, E203, E221, E222, E225, E302
43-
matplotlib/legend_handler.py: E201, E501
4443
matplotlib/mathtext.py: E201, E202, E203, E211, E221, E222, E225, E251, E301, E402
45-
matplotlib/patheffects.py: E231
4644
matplotlib/projections/geo.py: E203, E221, E231, E261, E502
4745
matplotlib/pylab.py: E501
4846
matplotlib/pyplot.py: E302, E701
4947
matplotlib/rcsetup.py: E203, E225, E261, E302, E501
50-
matplotlib/sphinxext/mathmpl.py: E302
51-
matplotlib/sphinxext/only_directives.py: E302
52-
matplotlib/sphinxext/plot_directive.py: E261, E302, E402
48+
matplotlib/sphinxext/plot_directive.py: E402
5349
matplotlib/tests/test_image.py: E231
5450
matplotlib/tests/test_mathtext.py: E501
5551
matplotlib/transforms.py: E201, E202, E203, E501

lib/matplotlib/legend_handler.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ def patch_func(legend=legend, orig_handle=orig_handle,
271271
xdescent=xdescent, ydescent=ydescent,
272272
width=width, height=height, fontsize=fontsize)
273273
274-
Subsequently the created artist will have its ``update_prop`` method
275-
called and the appropriate transform will be applied.
274+
Subsequently the created artist will have its ``update_prop``
275+
method called and the appropriate transform will be applied.
276276
277277
Notes
278278
-----
@@ -374,7 +374,7 @@ def update_prop(self, legend_handle, orig_handle, legend):
374374
self._update_prop(legend_handle, orig_handle)
375375

376376
legend_handle.set_figure(legend.figure)
377-
#legend._set_artist_props(legend_handle)
377+
# legend._set_artist_props(legend_handle)
378378
legend_handle.set_clip_box(None)
379379
legend_handle.set_clip_path(None)
380380

@@ -499,8 +499,8 @@ def create_artists(self, legend, orig_handle,
499499
handle_caplines = []
500500

501501
if orig_handle.has_xerr:
502-
verts = [ ((x - xerr_size, y), (x + xerr_size, y))
503-
for x, y in zip(xdata_marker, ydata_marker)]
502+
verts = [((x - xerr_size, y), (x + xerr_size, y))
503+
for x, y in zip(xdata_marker, ydata_marker)]
504504
coll = mcoll.LineCollection(verts)
505505
self.update_prop(coll, barlinecols[0], legend)
506506
handle_barlinecols.append(coll)
@@ -517,8 +517,8 @@ def create_artists(self, legend, orig_handle,
517517
handle_caplines.append(capline_right)
518518

519519
if orig_handle.has_yerr:
520-
verts = [ ((x, y - yerr_size), (x, y + yerr_size))
521-
for x, y in zip(xdata_marker, ydata_marker)]
520+
verts = [((x, y - yerr_size), (x, y + yerr_size))
521+
for x, y in zip(xdata_marker, ydata_marker)]
522522
coll = mcoll.LineCollection(verts)
523523
self.update_prop(coll, barlinecols[0], legend)
524524
handle_barlinecols.append(coll)
@@ -686,7 +686,8 @@ def create_artists(self, legend, orig_handle,
686686

687687
class HandlerPolyCollection(HandlerBase):
688688
"""
689-
Handler for `.PolyCollection` used in `~.Axes.fill_between` and `~.Axes.stackplot`.
689+
Handler for `.PolyCollection` used in `~.Axes.fill_between` and
690+
`~.Axes.stackplot`.
690691
"""
691692
def _update_prop(self, legend_handle, orig_handle):
692693
def first_color(colors):

lib/matplotlib/patheffects.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def draw_path(self, gc, tpath, affine, rgbFace=None):
104104
path_effect.draw_path(self._renderer, gc, tpath, affine,
105105
rgbFace)
106106

107-
def draw_markers(self, gc, marker_path, marker_trans, path, *args,
108-
**kwargs):
107+
def draw_markers(
108+
self, gc, marker_path, marker_trans, path, *args, **kwargs):
109109
# We do a little shimmy so that all markers are drawn for each path
110110
# effect in turn. Essentially, we induce recursion (depth 1) which is
111111
# terminated once we have just a single path effect to work with.
@@ -263,7 +263,7 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
263263
gc0.copy_properties(gc)
264264

265265
if self._shadow_rgbFace is None:
266-
r,g,b = (rgbFace or (1., 1., 1.))[:3]
266+
r, g, b = (rgbFace or (1., 1., 1.))[:3]
267267
# Scale the colors by a factor to improve the shadow effect.
268268
shadow_rgbFace = (r * self._rho, g * self._rho, b * self._rho)
269269
else:
@@ -291,7 +291,7 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
291291

292292
class SimpleLineShadow(AbstractPathEffect):
293293
"""A simple shadow via a line."""
294-
def __init__(self, offset=(2,-2),
294+
def __init__(self, offset=(2, -2),
295295
shadow_color='k', alpha=0.3, rho=0.3, **kwargs):
296296
"""
297297
Parameters
@@ -340,7 +340,7 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
340340
gc0.copy_properties(gc)
341341

342342
if self._shadow_color is None:
343-
r,g,b = (gc0.get_foreground() or (1., 1., 1.))[:3]
343+
r, g, b = (gc0.get_foreground() or (1., 1., 1.))[:3]
344344
# Scale the colors by a factor to improve the shadow effect.
345345
shadow_rgbFace = (r * self._rho, g * self._rho, b * self._rho)
346346
else:

lib/matplotlib/sphinxext/mathmpl.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111
rcParams['mathtext.fontset'] = 'cm'
1212
mathtext_parser = MathTextParser("Bitmap")
1313

14+
1415
# Define LaTeX math node:
1516
class latex_math(nodes.General, nodes.Element):
1617
pass
1718

19+
1820
def fontset_choice(arg):
1921
return directives.choice(arg, ['cm', 'stix', 'stixsans'])
2022

23+
2124
options_spec = {'fontset': fontset_choice}
2225

26+
2327
def math_role(role, rawtext, text, lineno, inliner,
2428
options={}, content=[]):
2529
i = rawtext.find('`')
@@ -28,8 +32,11 @@ def math_role(role, rawtext, text, lineno, inliner,
2832
node['latex'] = latex
2933
node['fontset'] = options.get('fontset', 'cm')
3034
return [node], []
35+
36+
3137
math_role.options = options_spec
3238

39+
3340
def math_directive(name, arguments, options, content, lineno,
3441
content_offset, block_text, state, state_machine):
3542
latex = ''.join(content)
@@ -38,6 +45,7 @@ def math_directive(name, arguments, options, content, lineno,
3845
node['fontset'] = options.get('fontset', 'cm')
3946
return [node]
4047

48+
4149
# This uses mathtext to render the expression
4250
def latex2png(latex, filename, fontset='cm'):
4351
latex = "$%s$" % latex
@@ -48,7 +56,7 @@ def latex2png(latex, filename, fontset='cm'):
4856
else:
4957
try:
5058
depth = mathtext_parser.to_png(filename, latex, dpi=100)
51-
except:
59+
except Exception:
5260
warnings.warn("Could not render math expression %s" % latex,
5361
Warning, stacklevel=2)
5462
depth = 0
@@ -57,6 +65,7 @@ def latex2png(latex, filename, fontset='cm'):
5765
sys.stdout.flush()
5866
return depth
5967

68+
6069
# LaTeX to HTML translation stuff:
6170
def latex2html(node, source):
6271
inline = isinstance(node.parent, nodes.TextElement)

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,11 @@
169169

170170
__version__ = 2
171171

172-
#------------------------------------------------------------------------------
172+
173+
# -----------------------------------------------------------------------------
173174
# Registration hook
174-
#------------------------------------------------------------------------------
175+
# -----------------------------------------------------------------------------
176+
175177

176178
def plot_directive(name, arguments, options, content, lineno,
177179
content_offset, block_text, state, state_machine):
@@ -275,9 +277,11 @@ def setup(app):
275277
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
276278
return metadata
277279

278-
#------------------------------------------------------------------------------
280+
281+
# -----------------------------------------------------------------------------
279282
# Doctest handling
280-
#------------------------------------------------------------------------------
283+
# -----------------------------------------------------------------------------
284+
281285

282286
def contains_doctest(text):
283287
try:
@@ -295,7 +299,6 @@ def unescape_doctest(text):
295299
"""
296300
Extract code from a piece of text, which contains either Python code
297301
or doctests.
298-
299302
"""
300303
if not contains_doctest(text):
301304
return text
@@ -313,11 +316,7 @@ def unescape_doctest(text):
313316

314317

315318
def split_code_at_show(text):
316-
"""
317-
Split code at plt.show()
318-
319-
"""
320-
319+
"""Split code at plt.show()."""
321320
parts = []
322321
is_doctest = contains_doctest(text)
323322

@@ -336,16 +335,15 @@ def split_code_at_show(text):
336335

337336

338337
def remove_coding(text):
339-
r"""
340-
Remove the coding comment, which six.exec\_ doesn't like.
341-
"""
338+
r"""Remove the coding comment, which six.exec\_ doesn't like."""
342339
cbook.warn_deprecated('3.0', name='remove_coding', removal='3.1')
343340
sub_re = re.compile(r"^#\s*-\*-\s*coding:\s*.*-\*-$", flags=re.MULTILINE)
344341
return sub_re.sub("", text)
345342

346-
#------------------------------------------------------------------------------
343+
344+
# -----------------------------------------------------------------------------
347345
# Template
348-
#------------------------------------------------------------------------------
346+
# -----------------------------------------------------------------------------
349347

350348

351349
TEMPLATE = """
@@ -425,6 +423,7 @@ def remove_coding(text):
425423
# :context: option
426424
plot_context = dict()
427425

426+
428427
class ImageFile(object):
429428
def __init__(self, basename, dirname):
430429
self.basename = basename
@@ -711,7 +710,7 @@ def run(arguments, content, options, state_machine, state, lineno):
711710
dest_dir = os.path.abspath(os.path.join(setup.app.builder.outdir,
712711
source_rel_dir))
713712
if not os.path.exists(dest_dir):
714-
os.makedirs(dest_dir) # no problem here for me, but just use built-ins
713+
os.makedirs(dest_dir) # no problem here for me, but just use built-ins
715714

716715
# how to link to files from the RST file
717716
dest_dir_link = os.path.join(relpath(setup.confdir, rst_dir),

0 commit comments

Comments
 (0)