Skip to content

Commit 2ff768e

Browse files
committed
Cleanup unused variables
This includes local variables and parameters of internal functions.
1 parent 0237ee0 commit 2ff768e

File tree

12 files changed

+19
-29
lines changed

12 files changed

+19
-29
lines changed

examples/event_handling/close_event.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import matplotlib.pyplot as plt
99

1010

11-
def handle_close(evt):
11+
def on_close(event):
1212
print('Closed Figure!')
1313

1414
fig = plt.figure()
15-
fig.canvas.mpl_connect('close_event', handle_close)
15+
fig.canvas.mpl_connect('close_event', on_close)
1616

1717
plt.text(0.35, 0.5, 'Close Me!', dict(size=30))
1818
plt.show()

examples/text_labels_and_annotations/arrow_demo.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,10 @@ def do_fontsize(k):
110110
return float(np.clip(max_text_size * np.sqrt(data[k]),
111111
min_text_size, max_text_size))
112112

113-
A = plt.text(0, 1, '$A_3$', color='r', size=do_fontsize('A'),
114-
**text_params)
115-
T = plt.text(1, 1, '$T_3$', color='k', size=do_fontsize('T'),
116-
**text_params)
117-
G = plt.text(0, 0, '$G_3$', color='g', size=do_fontsize('G'),
118-
**text_params)
119-
C = plt.text(1, 0, '$C_3$', color='b', size=do_fontsize('C'),
120-
**text_params)
113+
plt.text(0, 1, '$A_3$', color='r', size=do_fontsize('A'), **text_params)
114+
plt.text(1, 1, '$T_3$', color='k', size=do_fontsize('T'), **text_params)
115+
plt.text(0, 0, '$G_3$', color='g', size=do_fontsize('G'), **text_params)
116+
plt.text(1, 0, '$C_3$', color='b', size=do_fontsize('C'), **text_params)
121117

122118
arrow_h_offset = 0.25 # data coordinates, empirically determined
123119
max_arrow_length = 1 - 2 * arrow_h_offset

lib/matplotlib/backends/backend_gtk3.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def __init__(self, canvas, num):
364364
self.toolbar = self._get_toolbar()
365365
self.statusbar = None
366366

367-
def add_widget(child, expand, fill, padding):
367+
def add_widget(child):
368368
child.show()
369369
self.vbox.pack_end(child, False, False, 0)
370370
size_request = child.size_request()
@@ -375,12 +375,12 @@ def add_widget(child, expand, fill, padding):
375375
if self.toolbar:
376376
backend_tools.add_tools_to_container(self.toolbar)
377377
self.statusbar = StatusbarGTK3(self.toolmanager)
378-
h += add_widget(self.statusbar, False, False, 0)
379-
h += add_widget(Gtk.HSeparator(), False, False, 0)
378+
h += add_widget(self.statusbar)
379+
h += add_widget(Gtk.HSeparator())
380380

381381
if self.toolbar is not None:
382382
self.toolbar.show()
383-
h += add_widget(self.toolbar, False, False, 0)
383+
h += add_widget(self.toolbar)
384384

385385
self.window.set_default_size(w, h)
386386

lib/matplotlib/backends/backend_pdf.py

-1
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,6 @@ def _unpack(self, im):
14181418
``(height, width, 3)`` (RGB) or ``(height, width, 1)`` (grayscale or
14191419
alpha), except that alpha is None if the image is fully opaque.
14201420
"""
1421-
h, w = im.shape[:2]
14221421
im = im[::-1]
14231422
if im.ndim == 2:
14241423
return im, None

lib/matplotlib/backends/backend_ps.py

-2
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,6 @@ def draw_image(self, gc, x, y, im, transform=None):
299299
xscale = 1.0
300300
yscale = 1.0
301301

302-
figh = self.height * 72
303-
304302
bbox = gc.get_clip_rectangle()
305303
clippath, clippath_trans = gc.get_clip_path()
306304

lib/matplotlib/contour.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ def _autolev(self, N):
11401140

11411141
return lev[i0:i1]
11421142

1143-
def _contour_level_args(self, z, args):
1143+
def _process_contour_level_args(self, args):
11441144
"""
11451145
Determine the contour levels and store in self.levels.
11461146
"""
@@ -1484,7 +1484,7 @@ def _contour_args(self, args, kwargs):
14841484
cbook._warn_external('Log scale: values of z <= 0 have been '
14851485
'masked')
14861486
self.zmin = float(z.min())
1487-
self._contour_level_args(z, args)
1487+
self._process_contour_level_args(args)
14881488
return (x, y, z)
14891489

14901490
def _check_xyz(self, args, kwargs):

lib/matplotlib/offsetbox.py

-3
Original file line numberDiff line numberDiff line change
@@ -1271,9 +1271,6 @@ def _get_anchored_bbox(self, loc, bbox, parentbbox, borderpad):
12711271
class AnchoredText(AnchoredOffsetbox):
12721272
"""
12731273
AnchoredOffsetbox with Text.
1274-
1275-
This is a convenience class. Technically, it is just an `AnchoredOffsetbox`
1276-
containing a `TextArea`.
12771274
"""
12781275

12791276
def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs):

lib/matplotlib/tight_layout.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def auto_adjust_subplotpars(
9090
else:
9191
margin_top = None
9292

93-
vspaces = [[] for i in range((rows + 1) * cols)]
94-
hspaces = [[] for i in range(rows * (cols + 1))]
93+
vspaces = [[]] * ((rows + 1) * cols)
94+
hspaces = [[]] * (rows * (cols + 1))
9595

9696
union = Bbox.union
9797

lib/matplotlib/tri/tricontour.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _contour_args(self, args, kwargs):
9999
self.zmin = float(z_check.min())
100100
if self.logscale and self.zmin <= 0:
101101
raise ValueError('Cannot %s log of negative values.' % fn)
102-
self._contour_level_args(z, args[1:])
102+
self._process_contour_level_args(args[1:])
103103
return (tri, z)
104104

105105

lib/matplotlib/type1font.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def replacer(tokens):
291291
return replacer
292292

293293
def suppress(tokens):
294-
for x in itertools.takewhile(lambda x: x[1] != b'def', tokens):
294+
for _ in itertools.takewhile(lambda x: x[1] != b'def', tokens):
295295
pass
296296
yield b''
297297

lib/mpl_toolkits/axes_grid1/colorbar.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def __init__(self, ax,
386386
elif ticks is not None:
387387
self.cbar_axis.set_major_locator(ticks)
388388
else:
389-
self._select_locator(formatter)
389+
self._select_locator()
390390

391391
self._config_axes()
392392

@@ -563,7 +563,7 @@ def add_lines(self, levels, colors, linewidths):
563563
col.set_color(colors)
564564
self.ax.add_collection(col)
565565

566-
def _select_locator(self, formatter):
566+
def _select_locator(self):
567567
"""Select a suitable locator."""
568568
if self.boundaries is None:
569569
if isinstance(self.norm, colors.NoNorm):

tools/triage_tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(self, parent, index, name):
7272
layout.addWidget(self.image)
7373
self.setLayout(layout)
7474

75-
def mousePressEvent(self, ev):
75+
def mousePressEvent(self, event):
7676
self.parent.set_large_image(self.index)
7777

7878

0 commit comments

Comments
 (0)