Skip to content

Cleanup unused variables #16097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions examples/text_labels_and_annotations/arrow_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,10 @@ def do_fontsize(k):
return float(np.clip(max_text_size * np.sqrt(data[k]),
min_text_size, max_text_size))

A = plt.text(0, 1, '$A_3$', color='r', size=do_fontsize('A'),
**text_params)
T = plt.text(1, 1, '$T_3$', color='k', size=do_fontsize('T'),
**text_params)
G = plt.text(0, 0, '$G_3$', color='g', size=do_fontsize('G'),
**text_params)
C = plt.text(1, 0, '$C_3$', color='b', size=do_fontsize('C'),
**text_params)
plt.text(0, 1, '$A_3$', color='r', size=do_fontsize('A'), **text_params)
plt.text(1, 1, '$T_3$', color='k', size=do_fontsize('T'), **text_params)
plt.text(0, 0, '$G_3$', color='g', size=do_fontsize('G'), **text_params)
plt.text(1, 0, '$C_3$', color='b', size=do_fontsize('C'), **text_params)

arrow_h_offset = 0.25 # data coordinates, empirically determined
max_arrow_length = 1 - 2 * arrow_h_offset
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def __init__(self, canvas, num):
self.toolbar = self._get_toolbar()
self.statusbar = None

def add_widget(child, expand, fill, padding):
def add_widget(child):
child.show()
self.vbox.pack_end(child, False, False, 0)
size_request = child.size_request()
Expand All @@ -375,12 +375,12 @@ def add_widget(child, expand, fill, padding):
if self.toolbar:
backend_tools.add_tools_to_container(self.toolbar)
self.statusbar = StatusbarGTK3(self.toolmanager)
h += add_widget(self.statusbar, False, False, 0)
h += add_widget(Gtk.HSeparator(), False, False, 0)
h += add_widget(self.statusbar)
h += add_widget(Gtk.HSeparator())

if self.toolbar is not None:
self.toolbar.show()
h += add_widget(self.toolbar, False, False, 0)
h += add_widget(self.toolbar)

self.window.set_default_size(w, h)

Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,6 @@ def _unpack(self, im):
``(height, width, 3)`` (RGB) or ``(height, width, 1)`` (grayscale or
alpha), except that alpha is None if the image is fully opaque.
"""
h, w = im.shape[:2]
im = im[::-1]
if im.ndim == 2:
return im, None
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ def draw_image(self, gc, x, y, im, transform=None):
xscale = 1.0
yscale = 1.0

figh = self.height * 72

bbox = gc.get_clip_rectangle()
clippath, clippath_trans = gc.get_clip_path()

Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ def _autolev(self, N):

return lev[i0:i1]

def _contour_level_args(self, z, args):
def _process_contour_level_args(self, args):
"""
Determine the contour levels and store in self.levels.
"""
Expand Down Expand Up @@ -1484,7 +1484,7 @@ def _contour_args(self, args, kwargs):
cbook._warn_external('Log scale: values of z <= 0 have been '
'masked')
self.zmin = float(z.min())
self._contour_level_args(z, args)
self._process_contour_level_args(args)
return (x, y, z)

def _check_xyz(self, args, kwargs):
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tight_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def auto_adjust_subplotpars(
else:
margin_top = None

vspaces = [[] for i in range((rows + 1) * cols)]
hspaces = [[] for i in range(rows * (cols + 1))]
vspaces = [[] for _ in range((rows + 1) * cols)]
hspaces = [[] for _ in range(rows * (cols + 1))]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, I tried to shorten these further to

vspaces = [[]] * ((rows + 1) * cols)
hspaces = [[]] * (rows * (cols + 1))

But for some reason, this caused test failures.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it is not the same thing:

>python -c "a = [[]] * 2; a[0].append(123); print(a)"
[[123], [123]]

P.S: I think those can be turned into numpy arrays of python lists.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, of course it's not the same. 🙄

I leave numpy-fication for later. I suspect one could use numpy also further down to speed things up a little, but it needs a closer look.


union = Bbox.union

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tri/tricontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _contour_args(self, args, kwargs):
self.zmin = float(z_check.min())
if self.logscale and self.zmin <= 0:
raise ValueError('Cannot %s log of negative values.' % fn)
self._contour_level_args(z, args[1:])
self._process_contour_level_args(args[1:])
return (tri, z)


Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/type1font.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def replacer(tokens):
return replacer

def suppress(tokens):
for x in itertools.takewhile(lambda x: x[1] != b'def', tokens):
for _ in itertools.takewhile(lambda x: x[1] != b'def', tokens):
pass
yield b''

Expand Down
4 changes: 2 additions & 2 deletions lib/mpl_toolkits/axes_grid1/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def __init__(self, ax,
elif ticks is not None:
self.cbar_axis.set_major_locator(ticks)
else:
self._select_locator(formatter)
self._select_locator()

self._config_axes()

Expand Down Expand Up @@ -563,7 +563,7 @@ def add_lines(self, levels, colors, linewidths):
col.set_color(colors)
self.ax.add_collection(col)

def _select_locator(self, formatter):
def _select_locator(self):
"""Select a suitable locator."""
if self.boundaries is None:
if isinstance(self.norm, colors.NoNorm):
Expand Down