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

Skip to content

Commit 16d639b

Browse files
committed
Cleanup some "variable assigned but not used" lints.
Quite a few are left, some for clarity (for now...), others because they may possibly hint at underlying bugs.
1 parent 319f24f commit 16d639b

File tree

6 files changed

+11
-20
lines changed

6 files changed

+11
-20
lines changed

lib/matplotlib/_constrained_layout.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,11 @@ def _check_no_collapsed_axes(fig):
150150
return True
151151

152152

153-
def _get_margin_from_padding(object, *, w_pad=0, h_pad=0,
153+
def _get_margin_from_padding(obj, *, w_pad=0, h_pad=0,
154154
hspace=0, wspace=0):
155155

156-
ss = object._subplotspec
156+
ss = obj._subplotspec
157157
gs = ss.get_gridspec()
158-
lg = gs._layoutgrid
159158

160159
if hasattr(gs, 'hspace'):
161160
_hspace = (gs.hspace if gs.hspace is not None else hspace)
@@ -220,7 +219,6 @@ def _make_layout_margins(fig, renderer, *, w_pad=0, h_pad=0,
220219

221220
margin = _get_margin_from_padding(ax, w_pad=w_pad, h_pad=h_pad,
222221
hspace=hspace, wspace=wspace)
223-
margin0 = margin.copy()
224222
pos, bbox = _get_pos_and_bbox(ax, renderer)
225223
# the margin is the distance between the bounding box of the axes
226224
# and its position (plus the padding from above)
@@ -488,9 +486,6 @@ def _reposition_axes(fig, renderer, *, w_pad=0, h_pad=0, hspace=0, wspace=0):
488486

489487
bbox = gs._layoutgrid.get_inner_bbox(rows=ss.rowspan, cols=ss.colspan)
490488

491-
bboxouter = gs._layoutgrid.get_outer_bbox(rows=ss.rowspan,
492-
cols=ss.colspan)
493-
494489
# transform from figure to panel for set_position:
495490
newbbox = trans_fig_to_subfig.transform_bbox(bbox)
496491
ax._set_position(newbbox)
@@ -501,8 +496,7 @@ def _reposition_axes(fig, renderer, *, w_pad=0, h_pad=0, hspace=0, wspace=0):
501496
offset = {'left': 0, 'right': 0, 'bottom': 0, 'top': 0}
502497
for nn, cbax in enumerate(ax._colorbars[::-1]):
503498
if ax == cbax._colorbar_info['parents'][0]:
504-
margin = _reposition_colorbar(
505-
cbax, renderer, offset=offset)
499+
_reposition_colorbar(cbax, renderer, offset=offset)
506500

507501

508502
def _reposition_colorbar(cbax, renderer, *, offset=None):
@@ -527,7 +521,6 @@ def _reposition_colorbar(cbax, renderer, *, offset=None):
527521

528522
parents = cbax._colorbar_info['parents']
529523
gs = parents[0].get_gridspec()
530-
ncols, nrows = gs.ncols, gs.nrows
531524
fig = cbax.figure
532525
trans_fig_to_subfig = fig.transFigure - fig.transSubfigure
533526

lib/matplotlib/afm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def _parse_composites(fh):
312312
return composites
313313
vals = line.split(b';')
314314
cc = vals[0].split()
315-
name, numParts = cc[1], _to_int(cc[2])
315+
name, _num_parts = cc[1], _to_int(cc[2])
316316
pccParts = []
317317
for s in vals[1:-1]:
318318
pcc = s.split()

lib/matplotlib/animation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ def grab_frame(self, **savefig_kwargs):
532532
buf = BytesIO()
533533
self.fig.savefig(
534534
buf, **{**savefig_kwargs, "format": "rgba", "dpi": self.dpi})
535-
renderer = self.fig.canvas.get_renderer()
536535
self._frames.append(Image.frombuffer(
537536
"RGBA", self.frame_size, buf.getbuffer(), "raw", "RGBA", 0, 1))
538537

lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def _get_image_inclusion_command():
373373
# Don't mess with backslashes on Windows.
374374
% cbook._get_data_path("images/matplotlib.png").as_posix())
375375
try:
376-
prompt = man._expect_prompt()
376+
man._expect_prompt()
377377
return r"\includegraphics"
378378
except LatexError:
379379
# Discard the broken manager.

lib/matplotlib/colorbar.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,9 +1379,8 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
13791379
location = kw['ticklocation'] = loc_settings['location']
13801380

13811381
anchor = kw.pop('anchor', loc_settings['anchor'])
1382-
parent_anchor = kw.pop('panchor', loc_settings['panchor'])
1382+
panchor = kw.pop('panchor', loc_settings['panchor'])
13831383

1384-
parents_iterable = np.iterable(parents)
13851384
# turn parents into a list if it is not already. We do this w/ np
13861385
# because `plt.subplots` can return an ndarray and is natural to
13871386
# pass to `colorbar`.
@@ -1425,8 +1424,8 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
14251424
new_posn = shrinking_trans.transform(ax.get_position(original=True))
14261425
new_posn = mtransforms.Bbox(new_posn)
14271426
ax._set_position(new_posn)
1428-
if parent_anchor is not False:
1429-
ax.set_anchor(parent_anchor)
1427+
if panchor is not False:
1428+
ax.set_anchor(panchor)
14301429

14311430
cax = fig.add_axes(pbcb, label="<colorbar>")
14321431
for a in parents:
@@ -1437,7 +1436,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
14371436
parents=parents,
14381437
shrink=shrink,
14391438
anchor=anchor,
1440-
panchor=parent_anchor,
1439+
panchor=panchor,
14411440
fraction=fraction,
14421441
aspect=aspect,
14431442
pad=pad)
@@ -1539,7 +1538,7 @@ def make_axes_gridspec(parent, *, location=None, orientation=None,
15391538
aspect = 1 / aspect
15401539

15411540
parent.set_subplotspec(ss_main)
1542-
parent.set_anchor(loc_settings["panchor"])
1541+
parent.set_anchor(panchor)
15431542

15441543
fig = parent.get_figure()
15451544
cax = fig.add_subplot(ss_cb, label="<colorbar>")

lib/matplotlib/font_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ def _load_fontmanager(*, try_read_cache=True):
14141414
if try_read_cache:
14151415
try:
14161416
fm = json_load(fm_path)
1417-
except Exception as exc:
1417+
except Exception:
14181418
pass
14191419
else:
14201420
if getattr(fm, "_version", object()) == FontManager.__version__:

0 commit comments

Comments
 (0)