Skip to content

Removed unused variables etc. #22160

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 2 commits into from
Jan 10, 2022
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
1 change: 0 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,6 @@ def test(verbosity=None, coverage=False, **kwargs):
return -1

old_backend = get_backend()
old_recursionlimit = sys.getrecursionlimit()
try:
use('agg')

Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2153,7 +2153,7 @@ def _convert_dx(dx, x0, xconv, convert):
try:
x0 = cbook.safe_first_element(x0)
except (TypeError, IndexError, KeyError):
x0 = x0
pass

try:
x = cbook.safe_first_element(xconv)
Expand Down Expand Up @@ -5516,7 +5516,7 @@ def _pcolorargs(self, funcname, *args, shading='auto', **kwargs):
_valid_shading = ['gouraud', 'nearest', 'flat', 'auto']
try:
_api.check_in_list(_valid_shading, shading=shading)
except ValueError as err:
except ValueError:
_api.warn_external(f"shading value '{shading}' not in list of "
f"valid values {_valid_shading}. Setting "
"shading='auto'.")
Expand Down Expand Up @@ -7488,7 +7488,8 @@ def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
"""
cxy, freqs = mlab.cohere(x=x, y=y, NFFT=NFFT, Fs=Fs, detrend=detrend,
window=window, noverlap=noverlap,
scale_by_freq=scale_by_freq)
scale_by_freq=scale_by_freq, sides=sides,
Copy link
Member Author

Choose a reason for hiding this comment

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

My code analysis tool said that sides and pad_to was unused. I assume that they should be passed on (as otherwise these will not have any effect when calling cohere on an Axes).

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that should be passed on. Seems it never worked, but nobody ever complained... You can correct this.

Copy link
Member Author

Choose a reason for hiding this comment

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

They are passed on.

pad_to=pad_to)
freqs += Fc

self.plot(freqs, cxy, **kwargs)
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/quiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,6 @@ def __init__(self, ax, *args,
transform = kwargs.pop('transform', ax.transData)
self._pivot = pivot
self._length = length
barbcolor = barbcolor
flagcolor = flagcolor

# Flagcolor and barbcolor provide convenience parameters for
# setting the facecolor and edgecolor, respectively, of the barb
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ def _get_layout(self, renderer):
xmax = width
ymax = 0
ymin = ys[-1] - descent # baseline of last line minus its descent
height = ymax - ymin

# get the rotation matrix
M = Affine2D().rotate_deg(self.get_rotation())
Expand Down
3 changes: 0 additions & 3 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3066,9 +3066,6 @@ def _onmove(self, event):
- Re-size
- Continue the creation of a new shape
"""
state = self._state
rotate = ('rotate' in state and
self._active_handle in self._corner_order)
eventpress = self._eventpress
# The calculations are done for rotation at zero: we apply inverse
# transformation to events except when we rotate and move
Expand Down
25 changes: 12 additions & 13 deletions tools/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def subset_font(font_in, font_out, unicodes, opts):

def getsubset(subset, font_in):
subsets = subset.split('+')
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the code below, my guess is that if 'menu' in subset should probably have been if 'menu' in subsets and so on.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it probably was, but it works since subset is a string.

Tried to make a minimal change (and tried to search for the original code, but to no avail).

Copy link
Member

@timhoffm timhoffm Jan 9, 2022

Choose a reason for hiding this comment

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

+1 for changing the code below (or leaving as is for now with a comment if you don't dare to change it).

This code has been unchanged since it's addition in 2015, so there is no history to dig up.

Anyway, it's pretty obvious that this was an oversight and only accidentally worked. Checking subsets below is more clear, should be marginally faster, and is more safe in theory (even though it shouldn't make any practical difference for real use cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK! I'll change it. Both ways should work and using subsets is indeed probably more clear.

Copy link
Member

Choose a reason for hiding this comment

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

The if 'lang' in subset would be true if just lang-ext were in subset, but not now that we're checking subsets (which is correctly split). I don't know if this is a thing that might happen or if it's even going to be a problem, but this tool is internal anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you are correct. One can probably find such cases.


quotes = [
0x2013, # endash
0x2014, # emdash
Expand Down Expand Up @@ -220,16 +219,16 @@ def getsubset(subset, font_in):

result = quotes

if 'menu' in subset:
if 'menu' in subsets:
font = fontforge.open(font_in)
result = [
*map(ord, font.familyname),
0x0020,
]

if 'latin' in subset:
if 'latin' in subsets:
result += latin
if 'latin-ext' in subset:
if 'latin-ext' in subsets:
# These ranges include Extended A, B, C, D, and Additional with the
# exception of Vietnamese, which is a separate range
result += [
Expand All @@ -240,7 +239,7 @@ def getsubset(subset, font_in):
*range(0x2c60, 0x2c80),
*range(0xa700, 0xa800),
]
if 'vietnamese' in subset:
if 'vietnamese' in subsets:
# 2011-07-16 DC: Charset from
# http://vietunicode.sourceforge.net/charset/ + U+1ef9 from Fontaine
result += [0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00C8, 0x00C9,
Expand All @@ -251,16 +250,16 @@ def getsubset(subset, font_in):
0x00FA, 0x00FD, 0x0102, 0x0103, 0x0110, 0x0111,
0x0128, 0x0129, 0x0168, 0x0169, 0x01A0, 0x01A1,
0x01AF, 0x01B0, 0x20AB, *range(0x1EA0, 0x1EFA)]
if 'greek' in subset:
if 'greek' in subsets:
# Could probably be more aggressive here and exclude archaic
# characters, but lack data
result += [*range(0x370, 0x400)]
if 'greek-ext' in subset:
if 'greek-ext' in subsets:
result += [*range(0x370, 0x400), *range(0x1f00, 0x2000)]
if 'cyrillic' in subset:
if 'cyrillic' in subsets:
# Based on character frequency analysis
result += [*range(0x400, 0x460), 0x490, 0x491, 0x4b0, 0x4b1, 0x2116]
if 'cyrillic-ext' in subset:
if 'cyrillic-ext' in subsets:
result += [
*range(0x400, 0x530),
0x20b4,
Expand All @@ -270,7 +269,7 @@ def getsubset(subset, font_in):
*range(0x2de0, 0x2e00),
*range(0xa640, 0xa6a0),
]
if 'arabic' in subset:
if 'arabic' in subsets:
# Based on Droid Arabic Kufi 1.0
result += [0x000D, 0x0020, 0x0621, 0x0627, 0x062D,
0x062F, 0x0631, 0x0633, 0x0635, 0x0637, 0x0639,
Expand Down Expand Up @@ -322,7 +321,7 @@ def getsubset(subset, font_in):
0x063b, 0x063c, 0x063d, 0x063e, 0x063f, 0x0620,
0x0674, 0x0674, 0x06EC]

if 'dejavu-ext' in subset:
if 'dejavu-ext' in subsets:
# add all glyphnames ending in .display
font = fontforge.open(font_in)
for glyph in font.glyphs():
Expand All @@ -335,10 +334,10 @@ def getsubset(subset, font_in):
# code for extracting vertical metrics from a TrueType font
class Sfnt:
def __init__(self, data):
version, numTables, _, _, _ = struct.unpack('>IHHHH', data[:12])
_, numTables, _, _, _ = struct.unpack('>IHHHH', data[:12])
self.tables = {}
for i in range(numTables):
tag, checkSum, offset, length = struct.unpack(
tag, _, offset, length = struct.unpack(
'>4sIII', data[12 + 16 * i: 28 + 16 * i])
self.tables[tag] = data[offset: offset + length]

Expand Down