diff --git a/.flake8 b/.flake8 index a9e84a81500e..57ef52d72ede 100644 --- a/.flake8 +++ b/.flake8 @@ -3,7 +3,7 @@ ignore = # Normal default E121,E123,E126,E226,E24,E704,W503,W504, # Additional ignores: - E122, E124, E125, E127, E128, E129, E131, + E122, E125, E127, E128, E129, E131, E265, E266, E305, E306, E722, E741, diff --git a/examples/color/custom_cmap.py b/examples/color/custom_cmap.py index eb3727d92786..0e55060cfd58 100644 --- a/examples/color/custom_cmap.py +++ b/examples/color/custom_cmap.py @@ -104,28 +104,28 @@ # --- Custom colormaps --- cdict1 = {'red': ((0.0, 0.0, 0.0), - (0.5, 0.0, 0.1), - (1.0, 1.0, 1.0)), + (0.5, 0.0, 0.1), + (1.0, 1.0, 1.0)), - 'green': ((0.0, 0.0, 0.0), - (1.0, 0.0, 0.0)), + 'green': ((0.0, 0.0, 0.0), + (1.0, 0.0, 0.0)), - 'blue': ((0.0, 0.0, 1.0), - (0.5, 0.1, 0.0), - (1.0, 0.0, 0.0)) - } + 'blue': ((0.0, 0.0, 1.0), + (0.5, 0.1, 0.0), + (1.0, 0.0, 0.0)) + } cdict2 = {'red': ((0.0, 0.0, 0.0), - (0.5, 0.0, 1.0), - (1.0, 0.1, 1.0)), + (0.5, 0.0, 1.0), + (1.0, 0.1, 1.0)), - 'green': ((0.0, 0.0, 0.0), - (1.0, 0.0, 0.0)), + 'green': ((0.0, 0.0, 0.0), + (1.0, 0.0, 0.0)), - 'blue': ((0.0, 0.0, 0.1), - (0.5, 1.0, 0.0), - (1.0, 0.0, 0.0)) - } + 'blue': ((0.0, 0.0, 0.1), + (0.5, 1.0, 0.0), + (1.0, 0.0, 0.0)) + } cdict3 = {'red': ((0.0, 0.0, 0.0), (0.25, 0.0, 0.0), @@ -133,18 +133,18 @@ (0.75, 1.0, 1.0), (1.0, 0.4, 1.0)), - 'green': ((0.0, 0.0, 0.0), - (0.25, 0.0, 0.0), - (0.5, 0.9, 0.9), - (0.75, 0.0, 0.0), - (1.0, 0.0, 0.0)), - - 'blue': ((0.0, 0.0, 0.4), - (0.25, 1.0, 1.0), - (0.5, 1.0, 0.8), - (0.75, 0.0, 0.0), - (1.0, 0.0, 0.0)) - } + 'green': ((0.0, 0.0, 0.0), + (0.25, 0.0, 0.0), + (0.5, 0.9, 0.9), + (0.75, 0.0, 0.0), + (1.0, 0.0, 0.0)), + + 'blue': ((0.0, 0.0, 0.4), + (0.25, 1.0, 1.0), + (0.5, 1.0, 0.8), + (0.75, 0.0, 0.0), + (1.0, 0.0, 0.0)) + } # Make a modified version of cdict3 with some transparency # in the middle of the range. diff --git a/examples/images_contours_and_fields/contour_demo.py b/examples/images_contours_and_fields/contour_demo.py index bfbffe41eb45..70e40b61744b 100644 --- a/examples/images_contours_and_fields/contour_demo.py +++ b/examples/images_contours_and_fields/contour_demo.py @@ -51,9 +51,7 @@ # You can force all the contours to be the same color. fig, ax = plt.subplots() -CS = ax.contour(X, Y, Z, 6, - colors='k', # negative contours will be dashed by default - ) +CS = ax.contour(X, Y, Z, 6, colors='k') # Negative contours default to dashed. ax.clabel(CS, fontsize=9, inline=1) ax.set_title('Single color - negative contours dashed') @@ -62,9 +60,7 @@ matplotlib.rcParams['contour.negative_linestyle'] = 'solid' fig, ax = plt.subplots() -CS = ax.contour(X, Y, Z, 6, - colors='k', # negative contours will be dashed by default - ) +CS = ax.contour(X, Y, Z, 6, colors='k') # Negative contours default to dashed. ax.clabel(CS, fontsize=9, inline=1) ax.set_title('Single color - negative contours solid') @@ -74,9 +70,9 @@ fig, ax = plt.subplots() CS = ax.contour(X, Y, Z, 6, - linewidths=np.arange(.5, 4, .5), - colors=('r', 'green', 'blue', (1, 1, 0), '#afeeee', '0.5') - ) + linewidths=np.arange(.5, 4, .5), + colors=('r', 'green', 'blue', (1, 1, 0), '#afeeee', '0.5'), + ) ax.clabel(CS, fontsize=9, inline=1) ax.set_title('Crazy lines') diff --git a/lib/matplotlib/backends/backend_gtk3.py b/lib/matplotlib/backends/backend_gtk3.py index 77df07a2733b..9153240d2eb4 100644 --- a/lib/matplotlib/backends/backend_gtk3.py +++ b/lib/matplotlib/backends/backend_gtk3.py @@ -629,8 +629,8 @@ def __init__(self, Gtk.STOCK_SAVE, Gtk.ResponseType.OK), path = None, filetypes = [], - default_filetype = None - ): + default_filetype = None, + ): super().__init__(title, parent, action, buttons) self.set_default_response(Gtk.ResponseType.OK) self.set_do_overwrite_confirmation(True) diff --git a/lib/matplotlib/fontconfig_pattern.py b/lib/matplotlib/fontconfig_pattern.py index d384bae07e5b..af2500d899f7 100644 --- a/lib/matplotlib/fontconfig_pattern.py +++ b/lib/matplotlib/fontconfig_pattern.py @@ -74,38 +74,38 @@ def __init__(self): (value_punc, value_punc)) \ .setParseAction(self._value) - families =(family - + ZeroOrMore( - Literal(',') - + family) - ).setParseAction(self._families) - - point_sizes =(size - + ZeroOrMore( - Literal(',') - + size) - ).setParseAction(self._point_sizes) - - property =( (name - + Suppress(Literal('=')) - + value - + ZeroOrMore( - Suppress(Literal(',')) - + value) - ) - | name - ).setParseAction(self._property) - - pattern =(Optional( - families) - + Optional( - Literal('-') - + point_sizes) - + ZeroOrMore( - Literal(':') - + property) - + StringEnd() - ) + families = (family + + ZeroOrMore( + Literal(',') + + family) + ).setParseAction(self._families) + + point_sizes = (size + + ZeroOrMore( + Literal(',') + + size) + ).setParseAction(self._point_sizes) + + property = ((name + + Suppress(Literal('=')) + + value + + ZeroOrMore( + Suppress(Literal(',')) + + value) + ) + | name + ).setParseAction(self._property) + + pattern = (Optional( + families) + + Optional( + Literal('-') + + point_sizes) + + ZeroOrMore( + Literal(':') + + property) + + StringEnd() + ) self._parser = pattern self.ParseException = ParseException diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index e2da8a5ece2d..75ac899f717f 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -3273,8 +3273,7 @@ def __init__(self, beginarrow=None, endarrow=None, super().__init__() def _get_arrow_wedge(self, x0, y0, x1, y1, - head_dist, cos_t, sin_t, linewidth - ): + head_dist, cos_t, sin_t, linewidth): """ Return the paths for arrow heads. Since arrow lines are drawn with capstyle=projected, The arrow goes beyond the diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index ad68ef23a4fa..ffc18f0eaada 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -526,9 +526,9 @@ def update_savefig_format(value): validate_ps_papersize = ValidateInStrings( 'ps_papersize', ['auto', 'letter', 'legal', 'ledger', - 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'a10', - 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'b10', - ], ignorecase=True) + 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'a10', + 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'b10', + ], ignorecase=True) def validate_ps_distiller(s): diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 5ce395c870e5..85c0c26f2076 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -552,7 +552,7 @@ def test_light_source_shading_default(): [1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00], [1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00], [1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00]] - ]).T + ]).T assert_array_almost_equal(rgb, expect, decimal=2) @@ -609,7 +609,7 @@ def test_light_source_masked_shading(): [1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00], [1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00], [1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00]], - ]).T + ]).T assert_array_almost_equal(rgb, expect, decimal=2) diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index 5738b971a869..cadde6ea856a 100644 --- a/lib/matplotlib/tests/test_rcparams.py +++ b/lib/matplotlib/tests/test_rcparams.py @@ -193,7 +193,8 @@ def generate_validator_testcases(valid): *((_, False) for _ in ('f', 'n', 'no', 'off', 'false', '0', 0, False))), 'fail': ((_, ValueError) - for _ in ('aardvark', 2, -1, [], ))}, + for _ in ('aardvark', 2, -1, [], )) + }, {'validator': validate_stringlist, 'success': (('', []), ('a,b', ['a', 'b']), @@ -206,11 +207,11 @@ def generate_validator_testcases(valid): (np.array(['a', 'b']), ['a', 'b']), ((1, 2), ['1', '2']), (np.array([1, 2]), ['1', '2']), - ), + ), 'fail': ((dict(), ValueError), (1, ValueError), - ) - }, + ) + }, {'validator': validate_nseq_int(2), 'success': ((_, [1, 2]) for _ in ('1, 2', [1.5, 2.5], [1, 2], @@ -219,7 +220,7 @@ def generate_validator_testcases(valid): for _ in ('aardvark', ('a', 1), (1, 2, 3) )) - }, + }, {'validator': validate_nseq_float(2), 'success': ((_, [1.5, 2.5]) for _ in ('1.5, 2.5', [1.5, 2.5], [1.5, 2.5], @@ -228,7 +229,7 @@ def generate_validator_testcases(valid): for _ in ('aardvark', ('a', 1), (1, 2, 3) )) - }, + }, {'validator': validate_cycler, 'success': (('cycler("color", "rgb")', cycler("color", 'rgb')), @@ -237,17 +238,17 @@ def generate_validator_testcases(valid): ("""(cycler("color", ["r", "g", "b"]) + cycler("mew", [2, 3, 5]))""", (cycler("color", 'rgb') + - cycler("markeredgewidth", [2, 3, 5]))), + cycler("markeredgewidth", [2, 3, 5]))), ("cycler(c='rgb', lw=[1, 2, 3])", cycler('color', 'rgb') + cycler('linewidth', [1, 2, 3])), ("cycler('c', 'rgb') * cycler('linestyle', ['-', '--'])", (cycler('color', 'rgb') * - cycler('linestyle', ['-', '--']))), + cycler('linestyle', ['-', '--']))), (cycler('ls', ['-', '--']), cycler('linestyle', ['-', '--'])), (cycler(mew=[2, 5]), cycler('markeredgewidth', [2, 5])), - ), + ), # This is *so* incredibly important: validate_cycler() eval's # an arbitrary string! I think I have it locked down enough, # and that is what this is testing. @@ -258,40 +259,40 @@ def generate_validator_testcases(valid): 'fail': ((4, ValueError), # Gotta be a string or Cycler object ('cycler("bleh, [])', ValueError), # syntax error ('Cycler("linewidth", [1, 2, 3])', - ValueError), # only 'cycler()' function is allowed + ValueError), # only 'cycler()' function is allowed ('1 + 2', ValueError), # doesn't produce a Cycler object ('os.system("echo Gotcha")', ValueError), # os not available ('import os', ValueError), # should not be able to import ('def badjuju(a): return a; badjuju(cycler("color", "rgb"))', - ValueError), # Should not be able to define anything - # even if it does return a cycler + ValueError), # Should not be able to define anything + # even if it does return a cycler ('cycler("waka", [1, 2, 3])', ValueError), # not a property ('cycler(c=[1, 2, 3])', ValueError), # invalid values ("cycler(lw=['a', 'b', 'c'])", ValueError), # invalid values (cycler('waka', [1, 3, 5]), ValueError), # not a property (cycler('color', ['C1', 'r', 'g']), ValueError) # no CN - ) - }, + ) + }, {'validator': validate_hatch, 'success': (('--|', '--|'), ('\\oO', '\\oO'), ('/+*/.x', '/+*/.x'), ('', '')), 'fail': (('--_', ValueError), - (8, ValueError), - ('X', ValueError)), - }, + (8, ValueError), + ('X', ValueError)), + }, {'validator': validate_colorlist, 'success': (('r,g,b', ['r', 'g', 'b']), (['r', 'g', 'b'], ['r', 'g', 'b']), ('r, ,', ['r']), (['', 'g', 'blue'], ['g', 'blue']), ([np.array([1, 0, 0]), np.array([0, 1, 0])], - np.array([[1, 0, 0], [0, 1, 0]])), + np.array([[1, 0, 0], [0, 1, 0]])), (np.array([[1, 0, 0], [0, 1, 0]]), - np.array([[1, 0, 0], [0, 1, 0]])), - ), + np.array([[1, 0, 0], [0, 1, 0]])), + ), 'fail': (('fish', ValueError), - ), - }, + ), + }, {'validator': validate_color, 'success': (('None', 'none'), ('none', 'none'), @@ -304,13 +305,13 @@ def generate_validator_testcases(valid): ('(0, 1, 0, 1)', [0.0, 1.0, 0.0, 1.0]), # RGBA tuple ((0, 1, 0, 1), (0, 1, 0, 1)), # non-string version ('(0, 1, "0.5")', [0.0, 1.0, 0.5]), # unusual but valid - ), + ), 'fail': (('tab:veryblue', ValueError), # invalid name ('(0, 1)', ValueError), # tuple with length < 3 ('(0, 1, 0, 1, 0)', ValueError), # tuple with length > 4 ('(0, 1, none)', ValueError), # cannot cast none to float - ), - }, + ), + }, {'validator': validate_hist_bins, 'success': (('auto', 'auto'), ('fd', 'fd'), @@ -321,7 +322,7 @@ def generate_validator_testcases(valid): ), 'fail': (('aardvark', ValueError), ) - }, + }, {'validator': validate_markevery, 'success': ((None, None), (1, 1), @@ -350,7 +351,7 @@ def generate_validator_testcases(valid): ('a', TypeError), (object(), TypeError) ) - }, + }, {'validator': _validate_linestyle, 'success': (('-', '-'), ('solid', 'solid'), ('--', '--'), ('dashed', 'dashed'), @@ -372,7 +373,7 @@ def generate_validator_testcases(valid): ([1, 2, 3], ValueError), # sequence with odd length (1.23, ValueError), # not a sequence ) - }, + }, ) for validator_dict in validation_tests: diff --git a/lib/mpl_toolkits/axes_grid1/colorbar.py b/lib/mpl_toolkits/axes_grid1/colorbar.py index cb2bc8edea21..c0f9fc1e5247 100644 --- a/lib/mpl_toolkits/axes_grid1/colorbar.py +++ b/lib/mpl_toolkits/axes_grid1/colorbar.py @@ -315,19 +315,20 @@ class ColorbarBase(cm.ScalarMappable): Useful public methods are :meth:`set_label` and :meth:`add_lines`. ''' - def __init__(self, ax, cmap=None, - norm=None, - alpha=1.0, - values=None, - boundaries=None, - orientation='vertical', - extend='neither', - spacing='uniform', # uniform or proportional - ticks=None, - format=None, - drawedges=False, - filled=True, - ): + def __init__(self, ax, + cmap=None, + norm=None, + alpha=1.0, + values=None, + boundaries=None, + orientation='vertical', + extend='neither', + spacing='uniform', # uniform or proportional + ticks=None, + format=None, + drawedges=False, + filled=True, + ): self.ax = ax if cmap is None: diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 81150a75b14f..948d6a96f208 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -2956,11 +2956,8 @@ def permutation_matrices(n): edgecolor, normals, lightsource ) - poly = art3d.Poly3DCollection(faces, - facecolors=facecolor, - edgecolors=edgecolor, - **kwargs - ) + poly = art3d.Poly3DCollection( + faces, facecolors=facecolor, edgecolors=edgecolor, **kwargs) self.add_collection3d(poly) polygons[coord] = poly