From 94ea287acb15c5afcfb452841cef18349251ace2 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sun, 18 Nov 2018 13:23:06 +0100 Subject: [PATCH] Remove unused variables --- lib/matplotlib/__init__.py | 2 +- lib/matplotlib/_layoutbox.py | 1 - lib/matplotlib/_version.py | 2 +- lib/matplotlib/artist.py | 1 - lib/matplotlib/backend_bases.py | 1 - lib/matplotlib/backends/_backend_tk.py | 2 +- lib/matplotlib/backends/backend_agg.py | 2 -- lib/matplotlib/backends/backend_gtk3cairo.py | 2 +- lib/matplotlib/backends/backend_wx.py | 11 +++---- lib/matplotlib/cbook/__init__.py | 2 +- lib/matplotlib/offsetbox.py | 5 --- lib/matplotlib/patches.py | 32 +++++++++----------- lib/matplotlib/text.py | 2 +- lib/matplotlib/widgets.py | 9 ------ lib/mpl_toolkits/axisartist/axislines.py | 9 ------ 15 files changed, 25 insertions(+), 58 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 7735b0cdd604..1a78e042538e 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -822,7 +822,7 @@ def __setitem__(self, key, val): "either import that binding first, or set the QT_API " "environment variable.") cbook.warn_deprecated( - "2.2", name=key, obj_type="rcparam", addendum=addendum) + version, name=key, obj_type="rcparam", addendum=addendum) elif key in _deprecated_ignore_map: version, alt_key = _deprecated_ignore_map[key] cbook.warn_deprecated( diff --git a/lib/matplotlib/_layoutbox.py b/lib/matplotlib/_layoutbox.py index 663b0ab88367..98d503fb13c3 100644 --- a/lib/matplotlib/_layoutbox.py +++ b/lib/matplotlib/_layoutbox.py @@ -707,7 +707,6 @@ def plot_children(fig, box, level=0, printit=True): if printit: print("Level:", level) for child in box.children: - rect = child.get_rect() if printit: print(child) ax.add_patch( diff --git a/lib/matplotlib/_version.py b/lib/matplotlib/_version.py index 8d8f9065481a..137ba1ecde6a 100644 --- a/lib/matplotlib/_version.py +++ b/lib/matplotlib/_version.py @@ -436,7 +436,7 @@ def get_versions(): # versionfile_source is the relative path from the top of the source # tree (where the .git directory might live) to this file. Invert # this to find the root from __file__. - for i in cfg.versionfile_source.split('/'): + for _ in cfg.versionfile_source.split('/'): root = os.path.dirname(root) except NameError: return {"version": "0+unknown", "full-revisionid": None, diff --git a/lib/matplotlib/artist.py b/lib/matplotlib/artist.py index 7fb017f262ad..3381852e48d9 100644 --- a/lib/matplotlib/artist.py +++ b/lib/matplotlib/artist.py @@ -1393,7 +1393,6 @@ def pprint_setters_rest(self, prop=None, leadingspace=4): return '%s%s: %s' % (pad, prop, accepts) attrs = sorted(self._get_setters_and_targets()) - lines = [] names = [self.aliased_name_rest(prop, target) for prop, target in attrs] diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 820afe2ec078..ce095ab52214 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -613,7 +613,6 @@ def get_text_width_height_descent(self, s, prop, ismath): """ if ismath == 'TeX': # todo: handle props - size = prop.get_size_in_points() texmanager = self._text2path.get_texmanager() fontsize = prop.get_size_in_points() w, h, d = texmanager.get_text_width_height_descent( diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py index c88ad48b4c20..eead7f7683ed 100644 --- a/lib/matplotlib/backends/_backend_tk.py +++ b/lib/matplotlib/backends/_backend_tk.py @@ -971,7 +971,7 @@ def init_window(self): canvas = type(self.canvas)(toolfig, master=self.window) toolfig.subplots_adjust(top=0.9) - _tool = SubplotTool(self.figure, toolfig) + SubplotTool(self.figure, toolfig) canvas.draw() canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1) self.window.protocol("WM_DELETE_WINDOW", self.destroy) diff --git a/lib/matplotlib/backends/backend_agg.py b/lib/matplotlib/backends/backend_agg.py index 2c9d1566f335..e1f7faa520e5 100644 --- a/lib/matplotlib/backends/backend_agg.py +++ b/lib/matplotlib/backends/backend_agg.py @@ -196,7 +196,6 @@ def get_text_width_height_descent(self, s, prop, ismath): if ismath in ["TeX", "TeX!"]: # todo: handle props - size = prop.get_size_in_points() texmanager = self.get_texmanager() fontsize = prop.get_size_in_points() w, h, d = texmanager.get_text_width_height_descent( @@ -389,7 +388,6 @@ def draw(self): # acquire a lock on the shared font cache RendererAgg.lock.acquire() - toolbar = self.toolbar try: self.figure.draw(self.renderer) # A GUI class may be need to update a window using this draw, so diff --git a/lib/matplotlib/backends/backend_gtk3cairo.py b/lib/matplotlib/backends/backend_gtk3cairo.py index 2c41137e33d4..9d0fc16a3044 100644 --- a/lib/matplotlib/backends/backend_gtk3cairo.py +++ b/lib/matplotlib/backends/backend_gtk3cairo.py @@ -21,7 +21,7 @@ def _render_figure(self, width, height): def on_draw_event(self, widget, ctx): """GtkDrawable draw event.""" - toolbar = self.toolbar + # toolbar = self.toolbar # if toolbar: # toolbar.set_cursor(cursors.WAIT) self._renderer.set_context(ctx) diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index e8732da48542..27d7b542b8ef 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -1138,7 +1138,6 @@ def __init__(self, num, fig): pos = wx.DefaultPosition else: pos = wx.Point(20, 20) - l, b, w, h = fig.bbox.bounds wx.Frame.__init__(self, parent=None, id=-1, pos=pos, title="Figure %d" % num) # Frame will be sized later by the Fit method @@ -1471,7 +1470,7 @@ def __init__(self, targetfig): canvas = FigureCanvasWx(self, -1, toolfig) # Create a figure manager to manage things - figmgr = FigureManager(canvas, 1, self) + FigureManager(canvas, 1, self) # Now put all into a sizer sizer = wx.BoxSizer(wx.VERTICAL) @@ -1479,7 +1478,7 @@ def __init__(self, targetfig): sizer.Add(canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(sizer) self.Fit() - tool = SubplotTool(targetfig, toolfig) + SubplotTool(targetfig, toolfig) class NavigationToolbar2Wx(NavigationToolbar2, wx.ToolBar): @@ -1540,7 +1539,7 @@ def configure_subplots(self, evt): canvas = self.get_canvas(frame, toolfig) # Create a figure manager to manage things - figmgr = FigureManager(canvas, 1, frame) + FigureManager(canvas, 1, frame) # Now put all into a sizer sizer = wx.BoxSizer(wx.VERTICAL) @@ -1548,7 +1547,7 @@ def configure_subplots(self, evt): sizer.Add(canvas, 1, wx.LEFT | wx.TOP | wx.GROW) frame.SetSizer(sizer) frame.Fit() - tool = SubplotTool(self.canvas.figure, toolfig) + SubplotTool(self.canvas.figure, toolfig) frame.Show() def save_figure(self, *args): @@ -1804,7 +1803,7 @@ def configure_subplots(self): sizer.Add(canvas, 1, wx.LEFT | wx.TOP | wx.GROW) frame.SetSizer(sizer) frame.Fit() - tool = SubplotTool(self.canvas.figure, toolfig) + SubplotTool(self.canvas.figure, toolfig) frame.Show() def get_canvas(self, frame, fig): diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index 8323d7e67373..44f030d74385 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -706,7 +706,7 @@ def bubble(self, o): bubbles.append(thiso) else: self.push(thiso) - for thiso in bubbles: + for _ in bubbles: self.push(o) return o diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py index c6c5b50a07c8..e96617a2bc2b 100644 --- a/lib/matplotlib/offsetbox.py +++ b/lib/matplotlib/offsetbox.py @@ -806,15 +806,12 @@ def get_window_extent(self, renderer): return mtransforms.Bbox.from_bounds(ox - xd, oy - yd, w, h) def get_extent(self, renderer): - clean_line, ismath = self._text.is_math_text(self._text._text) _, h_, d_ = renderer.get_text_width_height_descent( "lp", self._text._fontproperties, ismath=False) bbox, info, d = self._text._get_layout(renderer) w, h = bbox.width, bbox.height - line = info[-1][0] # last line - self._baseline_transform.clear() if len(info) > 1 and self._multilinebaseline: @@ -1543,8 +1540,6 @@ def _update_position_xybox(self, renderer, xy_pixel): ox1, oy1 = x, y if self.arrowprops: - x0, y0 = x, y - d = self.arrowprops.copy() # Use FancyArrowPatch if self.arrowprops has "arrowstyle" key. diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 19aff209369e..0b5e2a30b85f 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -3325,30 +3325,26 @@ def transmute(self, path, mutation_size, linewidth): x1, y1 = path.vertices[1] # If there is no room for an arrow and a line, then skip the arrow - has_begin_arrow = self.beginarrow and not (x0 == x1 and y0 == y1) - if has_begin_arrow: - verticesA, codesA, ddxA, ddyA = \ - self._get_arrow_wedge(x1, y1, x0, y0, - head_dist, cos_t, sin_t, - linewidth) - else: - verticesA, codesA = [], [] - ddxA, ddyA = 0., 0. + has_begin_arrow = self.beginarrow and (x0, y0) != (x1, y1) + verticesA, codesA, ddxA, ddyA = ( + self._get_arrow_wedge(x1, y1, x0, y0, + head_dist, cos_t, sin_t, linewidth) + if has_begin_arrow + else ([], [], 0, 0) + ) # end arrow x2, y2 = path.vertices[-2] x3, y3 = path.vertices[-1] # If there is no room for an arrow and a line, then skip the arrow - has_end_arrow = (self.endarrow and not (x2 == x3 and y2 == y3)) - if has_end_arrow: - verticesB, codesB, ddxB, ddyB = \ - self._get_arrow_wedge(x2, y2, x3, y3, - head_dist, cos_t, sin_t, - linewidth) - else: - verticesB, codesB = [], [] - ddxB, ddyB = 0., 0. + has_end_arrow = self.endarrow and (x2, y2) != (x3, y3) + verticesB, codesB, ddxB, ddyB = ( + self._get_arrow_wedge(x2, y2, x3, y3, + head_dist, cos_t, sin_t, linewidth) + if has_end_arrow + else ([], [], 0, 0) + ) # This simple code will not work if ddx, ddy is greater than the # separation between vertices. diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index ba04cfe55252..3ab842930de5 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -538,7 +538,7 @@ def _update_clip_properties(self): clip_path=self._clippath, clip_on=self._clipon) if self._bbox_patch: - bbox = self._bbox_patch.update(clipprops) + self._bbox_patch.update(clipprops) def set_clip_box(self, clipbox): # docstring inherited. diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index 8fe0837c2493..c03715fd2a1e 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -1134,15 +1134,6 @@ def __init__(self, targetfig, toolfig): self.targetfig = targetfig toolfig.subplots_adjust(left=0.2, right=0.9) - class toolbarfmt: - def __init__(self, slider): - self.slider = slider - - def __call__(self, x, y): - fmt = '%s=%s' % (self.slider.label.get_text(), - self.slider.valfmt) - return fmt % x - self.axleft = toolfig.add_subplot(711) self.axleft.set_title('Click on slider to adjust subplot param') self.axleft.set_navigate(False) diff --git a/lib/mpl_toolkits/axisartist/axislines.py b/lib/mpl_toolkits/axisartist/axislines.py index bd01304e86ad..3a33e98d5760 100644 --- a/lib/mpl_toolkits/axisartist/axislines.py +++ b/lib/mpl_toolkits/axisartist/axislines.py @@ -284,12 +284,6 @@ def get_axislabel_pos_angle(self, axes): get_label_transform() returns a transform of (transAxes+offset) """ - loc = self._axis_direction - #angle = dict(left=0, - # right=0, - # bottom=.5*np.pi, - # top=.5*np.pi)[loc] - if self.nth_coord == 0: angle = 0 else: @@ -450,9 +444,6 @@ def new_floating_axis(self, nth_coord, value, "'new_floating_axis' explicitly requires the axes keyword.") axes = self.axes - passthrough_point = (value, value) - transform = axes.transData - _helper = AxisArtistHelperRectlinear.Floating( axes, nth_coord, value, axis_direction)