Skip to content

Commit c53017e

Browse files
committed
Remove many unused variables.
They can be detected by removing the exclusion of F841 in .flake8. Some other unused variables have been left in, either for symmetry in the code or because their lack of use may possibly indicate a bug that needs to be investigated.
1 parent 559925e commit c53017e

File tree

24 files changed

+49
-78
lines changed

24 files changed

+49
-78
lines changed

doc/sphinxext/github.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
103103
:param options: Directive options for customization.
104104
:param content: The directive content for customization.
105105
"""
106-
app = inliner.document.settings.env.app
107106
ref = 'https://www.github.com/' + text
108107
node = nodes.reference(rawtext, text, refuri=ref, **options)
109108
return [node], []

examples/axes_grid1/demo_axes_grid.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@ def demo_simple_grid(fig):
2828
axes_pad=0.05,
2929
label_mode="1",
3030
)
31-
3231
Z, extent = get_demo_image()
3332
for ax in grid:
34-
im = ax.imshow(Z, extent=extent, interpolation="nearest")
35-
36-
# This only affects axes in first column and second row as share_all =
37-
# False.
33+
ax.imshow(Z, extent=extent, interpolation="nearest")
34+
# This only affects axes in first column and second row as share_all=False.
3835
grid.axes_llc.set_xticks([-2, 0, 2])
3936
grid.axes_llc.set_yticks([-2, 0, 2])
4037

examples/axes_grid1/demo_edge_colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def demo_bottom_cbar(fig):
4141
im = grid[i].imshow(Z, extent=extent, interpolation="nearest",
4242
cmap=cmaps[i//2])
4343
if i % 2:
44-
cbar = grid.cbar_axes[i//2].colorbar(im)
44+
grid.cbar_axes[i//2].colorbar(im)
4545

4646
for cax in grid.cbar_axes:
4747
cax.toggle_label(True)

examples/event_handling/pick_event_demo.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def pick_simple():
8383
line, = ax1.plot(rand(100), 'o', picker=5) # 5 points tolerance
8484

8585
# pick the rectangle
86-
bars = ax2.bar(range(10), rand(10), picker=True)
86+
ax2.bar(range(10), rand(10), picker=True)
8787
for label in ax2.get_xticklabels(): # make the xtick labels pickable
8888
label.set_picker(True)
8989

@@ -157,18 +157,17 @@ def onpick3(event):
157157
print('onpick3 scatter:', ind, x[ind], y[ind])
158158

159159
fig, ax = plt.subplots()
160-
col = ax.scatter(x, y, 100*s, c, picker=True)
161-
#fig.savefig('pscoll.eps')
160+
ax.scatter(x, y, 100*s, c, picker=True)
162161
fig.canvas.mpl_connect('pick_event', onpick3)
163162

164163

165164
def pick_image():
166165
# picking images (matplotlib.image.AxesImage)
167166
fig, ax = plt.subplots()
168-
im1 = ax.imshow(rand(10, 5), extent=(1, 2, 1, 2), picker=True)
169-
im2 = ax.imshow(rand(5, 10), extent=(3, 4, 1, 2), picker=True)
170-
im3 = ax.imshow(rand(20, 25), extent=(1, 2, 3, 4), picker=True)
171-
im4 = ax.imshow(rand(30, 12), extent=(3, 4, 3, 4), picker=True)
167+
ax.imshow(rand(10, 5), extent=(1, 2, 1, 2), picker=True)
168+
ax.imshow(rand(5, 10), extent=(3, 4, 1, 2), picker=True)
169+
ax.imshow(rand(20, 25), extent=(1, 2, 3, 4), picker=True)
170+
ax.imshow(rand(30, 12), extent=(3, 4, 3, 4), picker=True)
172171
ax.axis([0, 5, 0, 5])
173172

174173
def onpick4(event):

examples/misc/demo_agg_filter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ def filtered_text(ax):
187187
Z = (Z1 - Z2) * 2
188188

189189
# draw
190-
im = ax.imshow(Z, interpolation='bilinear', origin='lower',
191-
cmap=cm.gray, extent=(-3, 3, -2, 2))
190+
ax.imshow(Z, interpolation='bilinear', origin='lower',
191+
cmap=cm.gray, extent=(-3, 3, -2, 2))
192192
levels = np.arange(-1.2, 1.6, 0.2)
193193
CS = ax.contour(Z, levels,
194194
origin='lower',

examples/units/basic_units.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def __get__(self, obj, objtype=None):
2525
class TaggedValueMeta(type):
2626
def __init__(self, name, bases, dict):
2727
for fn_name in self._proxies:
28-
try:
29-
dummy = getattr(self, fn_name)
30-
except AttributeError:
28+
if not hasattr(self, fn_name):
3129
setattr(self, fn_name,
3230
ProxyDelegate(fn_name, self._proxies[fn_name]))
3331

examples/widgets/menu.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ def __init__(self, fig, menuitems):
132132
maxw = max(item.labelwidth for item in menuitems)
133133
maxh = max(item.labelheight for item in menuitems)
134134

135-
totalh = self.numitems*maxh + (self.numitems + 1)*2*MenuItem.pady
136-
137135
x0 = 100
138136
y0 = 400
139137

lib/matplotlib/axes/_secondary_axes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,14 @@ def _set_lims(self):
295295
if self._orientation == 'x':
296296
lims = self._parent.get_xlim()
297297
set_lim = self.set_xlim
298-
trans = self.xaxis.get_transform()
299298
if self._orientation == 'y':
300299
lims = self._parent.get_ylim()
301300
set_lim = self.set_ylim
302-
trans = self.yaxis.get_transform()
303301
order = lims[0] < lims[1]
304302
lims = self._functions[0](np.array(lims))
305303
neworder = lims[0] < lims[1]
306304
if neworder != order:
307-
# flip because the transform will take care of the flipping..
305+
# Flip because the transform will take care of the flipping.
308306
lims = lims[::-1]
309307
set_lim(lims)
310308

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def motion_notify_event(self, widget, event):
235235
if event.is_hint:
236236
t, x, y, state = event.window.get_pointer()
237237
else:
238-
x, y, state = event.x, event.y, event.get_state()
238+
x, y = event.x, event.y
239239

240240
# flipy so y=0 is bottom of canvas
241241
y = self.get_allocation().height - y
@@ -582,7 +582,8 @@ def configure_subplots(self, button):
582582
toolfig = Figure(figsize=(6, 3))
583583
canvas = self._get_canvas(toolfig)
584584
toolfig.subplots_adjust(top=0.9)
585-
tool = SubplotTool(self.canvas.figure, toolfig)
585+
# Need to keep a reference to the tool.
586+
_tool = SubplotTool(self.canvas.figure, toolfig)
586587

587588
w = int(toolfig.bbox.width)
588589
h = int(toolfig.bbox.height)

lib/matplotlib/backends/backend_gtk3agg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ def blit(self, bbox=None):
6161
bbox = self.figure.bbox
6262

6363
allocation = self.get_allocation()
64-
w, h = allocation.width, allocation.height
6564
x = int(bbox.x0)
66-
y = h - int(bbox.y1)
65+
y = allocation.height - int(bbox.y1)
6766
width = int(bbox.x1) - int(bbox.x0)
6867
height = int(bbox.y1) - int(bbox.y0)
6968

0 commit comments

Comments
 (0)