Skip to content

Commit

Permalink
Merge pull request matplotlib#20129 from anntzer/f841
Browse files Browse the repository at this point in the history
Cleanup some "variable assigned but not used" lints.
  • Loading branch information
QuLogic authored May 3, 2021
2 parents 9177280 + 16d639b commit a4a84e9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 20 deletions.
13 changes: 3 additions & 10 deletions lib/matplotlib/_constrained_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,11 @@ def _check_no_collapsed_axes(fig):
return True


def _get_margin_from_padding(object, *, w_pad=0, h_pad=0,
def _get_margin_from_padding(obj, *, w_pad=0, h_pad=0,
hspace=0, wspace=0):

ss = object._subplotspec
ss = obj._subplotspec
gs = ss.get_gridspec()
lg = gs._layoutgrid

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

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

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

bboxouter = gs._layoutgrid.get_outer_bbox(rows=ss.rowspan,
cols=ss.colspan)

# transform from figure to panel for set_position:
newbbox = trans_fig_to_subfig.transform_bbox(bbox)
ax._set_position(newbbox)
Expand All @@ -501,8 +496,7 @@ def _reposition_axes(fig, renderer, *, w_pad=0, h_pad=0, hspace=0, wspace=0):
offset = {'left': 0, 'right': 0, 'bottom': 0, 'top': 0}
for nn, cbax in enumerate(ax._colorbars[::-1]):
if ax == cbax._colorbar_info['parents'][0]:
margin = _reposition_colorbar(
cbax, renderer, offset=offset)
_reposition_colorbar(cbax, renderer, offset=offset)


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

parents = cbax._colorbar_info['parents']
gs = parents[0].get_gridspec()
ncols, nrows = gs.ncols, gs.nrows
fig = cbax.figure
trans_fig_to_subfig = fig.transFigure - fig.transSubfigure

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/afm.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def _parse_composites(fh):
return composites
vals = line.split(b';')
cc = vals[0].split()
name, numParts = cc[1], _to_int(cc[2])
name, _num_parts = cc[1], _to_int(cc[2])
pccParts = []
for s in vals[1:-1]:
pcc = s.split()
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ def grab_frame(self, **savefig_kwargs):
buf = BytesIO()
self.fig.savefig(
buf, **{**savefig_kwargs, "format": "rgba", "dpi": self.dpi})
renderer = self.fig.canvas.get_renderer()
self._frames.append(Image.frombuffer(
"RGBA", self.frame_size, buf.getbuffer(), "raw", "RGBA", 0, 1))

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def _get_image_inclusion_command():
# Don't mess with backslashes on Windows.
% cbook._get_data_path("images/matplotlib.png").as_posix())
try:
prompt = man._expect_prompt()
man._expect_prompt()
return r"\includegraphics"
except LatexError:
# Discard the broken manager.
Expand Down
11 changes: 5 additions & 6 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1379,9 +1379,8 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
location = kw['ticklocation'] = loc_settings['location']

anchor = kw.pop('anchor', loc_settings['anchor'])
parent_anchor = kw.pop('panchor', loc_settings['panchor'])
panchor = kw.pop('panchor', loc_settings['panchor'])

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

cax = fig.add_axes(pbcb, label="<colorbar>")
for a in parents:
Expand All @@ -1437,7 +1436,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
parents=parents,
shrink=shrink,
anchor=anchor,
panchor=parent_anchor,
panchor=panchor,
fraction=fraction,
aspect=aspect,
pad=pad)
Expand Down Expand Up @@ -1539,7 +1538,7 @@ def make_axes_gridspec(parent, *, location=None, orientation=None,
aspect = 1 / aspect

parent.set_subplotspec(ss_main)
parent.set_anchor(loc_settings["panchor"])
parent.set_anchor(panchor)

fig = parent.get_figure()
cax = fig.add_subplot(ss_cb, label="<colorbar>")
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ def _load_fontmanager(*, try_read_cache=True):
if try_read_cache:
try:
fm = json_load(fm_path)
except Exception as exc:
except Exception:
pass
else:
if getattr(fm, "_version", object()) == FontManager.__version__:
Expand Down

0 comments on commit a4a84e9

Please sign in to comment.