8000 Remove several unused variables · matplotlib/matplotlib@eec341a · GitHub
[go: up one dir, main page]

Skip to content

Commit eec341a

Browse files
committed
Remove several unused variables
1 parent 5f7f6a8 commit eec341a

18 files changed

+18
-38
lines changed

doc/sphinxext/redirect_from.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ class RedirectFrom(Directive):
9191
def run(self):
9292
redirected_doc, = self.arguments
9393
env = self.app.env
94-
builder = self.app.builder
9594
domain = env.get_domain('redirect_from')
9695
current_doc = env.path2doc(self.state.document.current_source)
9796
redirected_reldoc, _ = env.relfn2path(redirected_doc, current_doc)

examples/event_handling/coords_demo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def on_move(event):
2929
if event.inaxes:
3030
# get the x and y pixel coords
3131
x, y = event.x, event.y
32-
ax = event.inaxes # the axes instance
3332
print('data coords %f %f, pixel coords %f %f'
3433
% (event.xdata, event.ydata, x, y))
3534

examples/event_handling/pong_sgskip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def __init__(self, ax):
190190
animated=False)
191191
self.canvas.mpl_connect('key_press_event', self.on_key_press)
192192

193-
def draw(self, event):
193+
def draw(self):
194194
draw_artist = self.ax.draw_artist
195195
if self.background is None:
196196
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
@@ -318,7 +318,7 @@ def start_anim(event):
318318

319319
def local_draw():
320320
if animation.ax.get_renderer_cache():
321-
animation.draw(None)
321+
animation.draw()
322322
start_anim.timer.add_callback(local_draw)
323323
start_anim.timer.start()
324324
canvas.mpl_connect('draw_event', on_redraw)

lib/matplotlib/_docstring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def some_function(x):
3333
def __init__(self, *args, **kwargs):
3434
if args and kwargs:
3535
raise TypeError("Only positional or keyword args are allowed")
36-
self.params = params = args or kwargs
36+
self.params = args or kwargs
3737

3838
def __call__(self, func):
3939
if func.__doc__:

lib/matplotlib/_layoutgrid.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,7 @@ def seq_id():
507507
return '%06d' % next(_layoutboxobjnum)
508508

509509

510-
def print_children(lb):
511-
"""Print the children of the layoutbox."""
512-
for child in lb.children:
513-
print_children(child)
514-
515-
516-
def plot_children(fig, lg=None, level=0, printit=False):
510+
def plot_children(fig, lg=None, level=0):
517511
"""Simple plotting to show where boxes are."""
518512
import matplotlib.pyplot as plt
519513
import matplotlib.patches as mpatches

lib/matplotlib/backend_managers.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,24 +284,22 @@ def add_tool(self, name, tool, *args, **kwargs):
284284

285285
# If initially toggled
286286
if tool_obj.toggled:
287-
self._handle_toggle(tool_obj, None, None, None)
287+
self._handle_toggle(tool_obj, None, None)
288288
tool_obj.set_figure(self.figure)
289289

290290
event = ToolEvent('tool_added_event', self, tool_obj)
291291
self._callbacks.process(event.name, event)
292292

293293
return tool_obj
294294

295-
def _handle_toggle(self, tool, sender, canvasevent, data):
295+
def _handle_toggle(self, tool, canvasevent, data):
296296
"""
297297
Toggle tools, need to untoggle prior to using other Toggle tool.
298298
Called from trigger_tool.
299299
300300
Parameters
301301
----------
302302
tool : `.ToolBase`
303-
sender : object
304-
Object that wishes to trigger the tool.
305303
canvasevent : Event
306304
Original Canvas event or None.
307305
data : object
@@ -360,7 +358,7 @@ def trigger_tool(self, name, sender=None, canvasevent=None, data=None):
360358
sender = self
361359

362360
if isinstance(tool, backend_tools.ToolToggleBase):
363-
self._handle_toggle(tool, sender, canvasevent, data)
361+
self._handle_toggle(tool, canvasevent, data)
364362

365363
tool.trigger(sender, canvasevent, data) # Actually trigger Tool.
366364

lib/matplotlib/dviread.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ def _read(self):
356356
while True:
357357
byte = self.file.read(1)[0]
358358
self._dtable[byte](self, byte)
359-
name = self._dtable[byte].__name__
360359
if byte == 140: # end of page
361360
return True
362361
if self.state is _dvistate.post_post: # end of file

lib/matplotlib/font_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ def set_stretch(self, stretch):
890890
return
891891
try:
892892
stretch = int(stretch)
893-
except ValueError as err:
893+
except ValueError:
894894
pass
895895
else:
896896
if 0 <= stretch <= 1000:

lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3822,8 +3822,6 @@ def test_errorbar_nan(fig_test, fig_ref):
38223822
es = np.array([4, 5, np.nan, np.nan, 6])
38233823
ax.errorbar(xs, ys, es)
38243824
ax = fig_ref.add_subplot()
3825-
ys = np.array([1, 2, np.nan, np.nan, 3])
3826-
es = np.array([4, 5, np.nan, np.nan, 6])
38273825
ax.errorbar([0, 1], [1, 2], [4, 5])
38283826
ax.errorbar([4], [3], [6], fmt="C0")
38293827

@@ -7787,10 +7785,7 @@ def test_patch_bounds(): # PR 19078
77877785
def test_warn_ignored_scatter_kwargs():
77887786
with pytest.warns(UserWarning,
77897787
match=r"You passed a edgecolor/edgecolors"):
7790-
7791-
c = plt.scatter(
7792-
[0], [0], marker="+", s=500, facecolor="r", edgecolor="b"
7793-
)
7788+
plt.scatter([0], [0], marker="+", s=500, facecolor="r", edgecolor="b")
77947789

77957790

77967791
def test_artist_sublists():

lib/matplotlib/tests/test_backend_qt.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
@pytest.fixture
3131
def qt_core(request):
32-
backend, = request.node.get_closest_marker('backend').args
3332
qt_compat = pytest.importorskip('matplotlib.backends.qt_compat')
3433
QtCore = qt_compat.QtCore
3534

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def _get_testable_interactive_backends():
8080
# also necessary on gtk3 and wx, where directly processing a KeyEvent() for "q"
8181
# from draw_event causes breakage as the canvas widget gets deleted too early.
8282
def _test_interactive_impl():
83-
import importlib
8483
import importlib.util
8584
import io
8685
import json

lib/matplotlib/tests/test_collections.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,9 @@ def test_add_collection():
309309
# GitHub issue #1490, pull #1497.
310310
plt.figure()
311311
ax = plt.axes()
312-
coll = ax.scatter([0, 1], [0, 1])
313-
ax.add_collection(coll)
312+
ax.scatter([0, 1], [0, 1])
314313
bounds = ax.dataLim.bounds
315-
coll = ax.scatter([], [])
314+
ax.scatter([], [])
316315
assert ax.dataLim.bounds == bounds
317316

318317

lib/matplotlib/tests/test_constrainedlayout.py

Copy file name to clipboard
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def test_constrained_layout8():
165165
for i in ilist:
166166
ax = fig.add_subplot(gs[j, i])
167167
axs += [ax]
168-
pcm = example_pcolor(ax, fontsize=9)
168+
example_pcolor(ax, fontsize=9)
169169
if i > 0:
170170
ax.set_ylabel('')
171171
if j < 1:

lib/matplotlib/tests/test_dates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ def test_warn_notintervals():
11881188
locator.create_dummy_axis()
11891189
locator.axis.set_view_interval(mdates.date2num(dates[0]),
11901190
mdates.date2num(dates[-1]))
1191-
with pytest.warns(UserWarning, match="AutoDateLocator was unable") as rec:
1191+
with pytest.warns(UserWarning, match="AutoDateLocator was unable"):
11921192
locs = locator()
11931193

11941194

lib/matplotlib/tests/test_figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ def test_clf_not_redefined():
769769
@mpl.style.context('mpl20')
770770
def test_picking_does_not_stale():
771771
fig, ax = plt.subplots()
772-
col = ax.scatter([0], [0], [1000], picker=True)
772+
ax.scatter([0], [0], [1000], picker=True)
773773
fig.canvas.draw()
774774
assert not fig.stale
775775

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def test_divider_append_axes():
4040
"right": divider.append_axes("right", 1.2, pad=0.1, sharey=ax),
4141
}
4242
fig.canvas.draw()
43-
renderer = fig.canvas.get_renderer()
4443
bboxes = {k: axs[k].get_window_extent() for k in axs}
4544
dpi = fig.dpi
4645
assert bboxes["top"].height == pytest.approx(1.2 * dpi)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def prepare_flags(name, enable_lto):
133133
stdout=subprocess.PIPE,
134134
stderr=subprocess.STDOUT,
135135
universal_newlines=True)
136-
except Exception as e:
136+
except Exception:
137137
pass
138138
else:
139139
version = result.stdout.lower()

tutorials/intermediate/constrainedlayout_guide.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
650650
fig, ax = plt.subplots(1, 2, layout="constrained")
651651
example_plot(ax[0], fontsize=32)
652652
example_plot(ax[1], fontsize=8)
653-
plot_children(fig, printit=False)
653+
plot_children(fig)
654654

655655
#######################################################################
656656
# Two Axes and colorbar
@@ -676,7 +676,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
676676
for ax in axs.flat:
677677
im = ax.pcolormesh(arr, **pc_kwargs)
678678
fig.colorbar(im, ax=axs, shrink=0.6)
679-
plot_children(fig, printit=False)
679+
plot_children(fig)
680680

681681
#######################################################################
682682
# Uneven sized Axes
@@ -701,7 +701,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):
701701
im = ax.pcolormesh(arr, **pc_kwargs)
702702
ax = fig.add_subplot(gs[1, 1])
703703
im = ax.pcolormesh(arr, **pc_kwargs)
704-
plot_children(fig, printit=False)
704+
plot_children(fig)
705705

706706
#######################################################################
707707
# One case that requires finessing is if margins do not have any artists

0 commit comments

Comments
 (0)
0