From 1cba8173a6936793b1fe5eb5fd6b6a3d58a467b7 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 8 Jan 2022 18:56:15 +0100 Subject: [PATCH 1/2] Removed unused variables etc. --- lib/matplotlib/__init__.py | 1 - lib/matplotlib/axes/_axes.py | 4 ++-- lib/matplotlib/quiver.py | 2 -- lib/matplotlib/text.py | 1 - lib/matplotlib/widgets.py | 3 --- tools/subset.py | 25 ++++++++++++------------- 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 8eed28ce2caf..5937b547498f 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1229,7 +1229,6 @@ def test(verbosity=None, coverage=False, **kwargs): return -1 old_backend = get_backend() - old_recursionlimit = sys.getrecursionlimit() try: use('agg') diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index be4f171b8505..e001c52dc537 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -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) @@ -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'.") diff --git a/lib/matplotlib/quiver.py b/lib/matplotlib/quiver.py index 628b60be78ab..39f304b97e20 100644 --- a/lib/matplotlib/quiver.py +++ b/lib/matplotlib/quiver.py @@ -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 diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 66cc6c046ba6..4dcf40648d35 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -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()) diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index ffaa35ea8924..e330657ccbd4 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -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 diff --git a/tools/subset.py b/tools/subset.py index 53e8d5fd9400..8289d8b04e56 100644 --- a/tools/subset.py +++ b/tools/subset.py @@ -182,7 +182,6 @@ def subset_font(font_in, font_out, unicodes, opts): def getsubset(subset, font_in): subsets = subset.split('+') - quotes = [ 0x2013, # endash 0x2014, # emdash @@ -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 += [ @@ -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, @@ -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, @@ -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, @@ -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(): @@ -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] From 1e07fdbce15592c7baeb331ae66264eabac9a768 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Mon, 10 Jan 2022 10:51:32 +0100 Subject: [PATCH 2/2] Passed on sides and pad_to --- lib/matplotlib/axes/_axes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index e001c52dc537..a0c654bb3412 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -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, + pad_to=pad_to) freqs += Fc self.plot(freqs, cxy, **kwargs)