From 3c3c44d263e6a4314a543afc4d86e6224b108709 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 29 Jun 2018 14:55:49 +0100 Subject: [PATCH 1/2] Re-enable pep8 on examples folder --- examples/axisartist/demo_parasite_axes.py | 2 +- examples/axisartist/demo_parasite_axes2.py | 2 +- .../images_contours_and_fields/barb_demo.py | 1 - .../image_masked.py | 1 - .../images_contours_and_fields/pcolor_demo.py | 2 +- .../plot_streamplot.py | 1 - .../quiver_simple_demo.py | 1 - .../marker_reference.py | 5 +- examples/misc/histogram_path.py | 18 +++---- examples/pyplots/align_ylabels.py | 7 +-- examples/pyplots/pyplot_scales.py | 2 +- examples/specialty_plots/sankey_links.py | 1 - .../usetex_demo.py | 4 +- examples/units/basic_units.py | 2 +- pytest.ini | 54 +++++++++---------- 15 files changed, 49 insertions(+), 54 deletions(-) diff --git a/examples/axisartist/demo_parasite_axes.py b/examples/axisartist/demo_parasite_axes.py index 55c3d6e815d7..d7e852f96fe6 100644 --- a/examples/axisartist/demo_parasite_axes.py +++ b/examples/axisartist/demo_parasite_axes.py @@ -4,7 +4,7 @@ ================== Create a parasite axes. Such axes would share the x scale with a host axes, -but show a different scale in y direction. +but show a different scale in y direction. Note that this approach uses the `~mpl_toolkits.axes_grid1.parasite_axes`\' `~.mpl_toolkits.axes_grid1.parasite_axes.HostAxes` and diff --git a/examples/axisartist/demo_parasite_axes2.py b/examples/axisartist/demo_parasite_axes2.py index c89614658f9b..b2bf3b4b66da 100644 --- a/examples/axisartist/demo_parasite_axes2.py +++ b/examples/axisartist/demo_parasite_axes2.py @@ -14,7 +14,7 @@ Note that this approach uses the `mpl_toolkits.axes_grid1.parasite_axes`\' `~mpl_toolkits.axes_grid1.parasite_axes.host_subplot` and -`mpl_toolkits.axisartist.axislines.Axes`. An alternative approach using the +`mpl_toolkits.axisartist.axislines.Axes`. An alternative approach using the `~mpl_toolkits.axes_grid1.parasite_axes`\'s `~.mpl_toolkits.axes_grid1.parasite_axes.HostAxes` and `~.mpl_toolkits.axes_grid1.parasite_axes.ParasiteAxes` is the diff --git a/examples/images_contours_and_fields/barb_demo.py b/examples/images_contours_and_fields/barb_demo.py index 00331d64a703..950acc281fd0 100644 --- a/examples/images_contours_and_fields/barb_demo.py +++ b/examples/images_contours_and_fields/barb_demo.py @@ -65,4 +65,3 @@ import matplotlib matplotlib.axes.Axes.barbs matplotlib.pyplot.barbs - diff --git a/examples/images_contours_and_fields/image_masked.py b/examples/images_contours_and_fields/image_masked.py index af718c8536b7..b8f13c5726c8 100644 --- a/examples/images_contours_and_fields/image_masked.py +++ b/examples/images_contours_and_fields/image_masked.py @@ -91,4 +91,3 @@ matplotlib.pyplot.colorbar matplotlib.colors.BoundaryNorm matplotlib.colorbar.ColorbarBase.set_label - diff --git a/examples/images_contours_and_fields/pcolor_demo.py b/examples/images_contours_and_fields/pcolor_demo.py index 551b3238d145..2ddc0f3b5a4d 100644 --- a/examples/images_contours_and_fields/pcolor_demo.py +++ b/examples/images_contours_and_fields/pcolor_demo.py @@ -6,7 +6,7 @@ Generating images with :meth:`~.axes.Axes.pcolor`. Pcolor allows you to generate 2-D image-style plots. Below we will show how -to do so in Matplotlib. +to do so in Matplotlib. """ import matplotlib.pyplot as plt import numpy as np diff --git a/examples/images_contours_and_fields/plot_streamplot.py b/examples/images_contours_and_fields/plot_streamplot.py index 2f577c76d421..5f142899c86e 100644 --- a/examples/images_contours_and_fields/plot_streamplot.py +++ b/examples/images_contours_and_fields/plot_streamplot.py @@ -85,4 +85,3 @@ matplotlib.pyplot.streamplot matplotlib.gridspec matplotlib.gridspec.GridSpec - diff --git a/examples/images_contours_and_fields/quiver_simple_demo.py b/examples/images_contours_and_fields/quiver_simple_demo.py index 61d5e8ff5f63..0393a4857cbd 100644 --- a/examples/images_contours_and_fields/quiver_simple_demo.py +++ b/examples/images_contours_and_fields/quiver_simple_demo.py @@ -36,4 +36,3 @@ matplotlib.pyplot.quiver matplotlib.axes.Axes.quiverkey matplotlib.pyplot.quiverkey - diff --git a/examples/lines_bars_and_markers/marker_reference.py b/examples/lines_bars_and_markers/marker_reference.py index 715e8d685a80..829557c4647a 100644 --- a/examples/lines_bars_and_markers/marker_reference.py +++ b/examples/lines_bars_and_markers/marker_reference.py @@ -65,7 +65,6 @@ def split_list(a_list): plt.show() - ############################################################################### # Plot all filled markers. @@ -86,8 +85,8 @@ def split_list(a_list): # # # Use :doc:`MathText `, to use custom marker symbols, -# like e.g. ``"$\u266B$"``. For an overview over the STIX font symbols refer to the -# `STIX font table `_. +# like e.g. ``"$\u266B$"``. For an overview over the STIX font symbols refer +# to the `STIX font table `_. # Also see the :doc:`/gallery/text_labels_and_annotations/stix_fonts_demo`. diff --git a/examples/misc/histogram_path.py b/examples/misc/histogram_path.py index 1aeefb56a97e..4eb4d68ba2d5 100644 --- a/examples/misc/histogram_path.py +++ b/examples/misc/histogram_path.py @@ -65,14 +65,14 @@ codes = np.ones(nverts, int) * path.Path.LINETO codes[0::5] = path.Path.MOVETO codes[4::5] = path.Path.CLOSEPOLY -verts[0::5,0] = left -verts[0::5,1] = bottom -verts[1::5,0] = left -verts[1::5,1] = top -verts[2::5,0] = right -verts[2::5,1] = top -verts[3::5,0] = right -verts[3::5,1] = bottom +verts[0::5, 0] = left +verts[0::5, 1] = bottom +verts[1::5, 0] = left +verts[1::5, 1] = top +verts[2::5, 0] = right +verts[2::5, 1] = top +verts[3::5, 0] = right +verts[3::5, 1] = bottom barpath = path.Path(verts, codes) @@ -95,6 +95,6 @@ matplotlib.axes.Axes.add_patch matplotlib.collections.PathCollection -# This example shows an alternative to +# This example shows an alternative to matplotlib.collections.PolyCollection matplotlib.axes.Axes.hist diff --git a/examples/pyplots/align_ylabels.py b/examples/pyplots/align_ylabels.py index fed5d83c5ce5..09711eef28aa 100644 --- a/examples/pyplots/align_ylabels.py +++ b/examples/pyplots/align_ylabels.py @@ -10,6 +10,7 @@ import numpy as np import matplotlib.pyplot as plt + def make_plot(axs): box = dict(facecolor='yellow', pad=5, alpha=0.2) @@ -22,7 +23,7 @@ def make_plot(axs): ax1.set_ylim(0, 2000) ax3 = axs[1, 0] - ax3.set_ylabel('misaligned 2',bbox=box) + ax3.set_ylabel('misaligned 2', bbox=box) ax3.plot(np.random.rand(10)) ax2 = axs[0, 1] @@ -35,14 +36,14 @@ def make_plot(axs): ax4.plot(np.random.rand(10)) ax4.set_ylabel('aligned 2', bbox=box) -# Plot 1: +# Plot 1: fig, axs = plt.subplots(2, 2) fig.subplots_adjust(left=0.2, wspace=0.6) make_plot(axs) # just align the last column of axes: -fig.align_ylabels(axs[:,1]) +fig.align_ylabels(axs[:, 1]) plt.show() ############################################################################# diff --git a/examples/pyplots/pyplot_scales.py b/examples/pyplots/pyplot_scales.py index 910d11323dbe..a45647b88dda 100644 --- a/examples/pyplots/pyplot_scales.py +++ b/examples/pyplots/pyplot_scales.py @@ -79,4 +79,4 @@ matplotlib.pyplot.gca matplotlib.pyplot.yscale matplotlib.ticker.NullFormatter -matplotlib.axis.Axis.set_minor_formatter +matplotlib.axis.Axis.set_minor_formatter diff --git a/examples/specialty_plots/sankey_links.py b/examples/specialty_plots/sankey_links.py index d53d8e34b172..7221d3592058 100644 --- a/examples/specialty_plots/sankey_links.py +++ b/examples/specialty_plots/sankey_links.py @@ -73,4 +73,3 @@ def corner(sankey): matplotlib.sankey.Sankey matplotlib.sankey.Sankey.add matplotlib.sankey.Sankey.finish - diff --git a/examples/text_labels_and_annotations/usetex_demo.py b/examples/text_labels_and_annotations/usetex_demo.py index 390ddea6c646..6d5392edadb4 100644 --- a/examples/text_labels_and_annotations/usetex_demo.py +++ b/examples/text_labels_and_annotations/usetex_demo.py @@ -29,8 +29,8 @@ xytext=(delta / 2., 0.1), textcoords='data', arrowprops=dict(arrowstyle="<->", connectionstyle="arc3")) plt.text(0, 0.1, r'$\delta$', - {'color': 'k', 'fontsize': 24, 'ha' : 'center', 'va' : 'center', - 'bbox' : dict(boxstyle="round", fc="w", ec="k", pad=0.2)}) + {'color': 'k', 'fontsize': 24, 'ha': 'center', 'va': 'center', + 'bbox': dict(boxstyle="round", fc="w", ec="k", pad=0.2)}) # Use tex in labels plt.xticks((-1, 0, 1), ('$-1$', r'$\pm 0$', '$+1$'), color='k', size=20) diff --git a/examples/units/basic_units.py b/examples/units/basic_units.py index aae4325fd3f2..ed6990e1aa40 100644 --- a/examples/units/basic_units.py +++ b/examples/units/basic_units.py @@ -301,7 +301,7 @@ def rad_fn(x, pos=None): n = int((x / np.pi) * 2.0 + 0.25) else: n = int((x / np.pi) * 2.0 - 0.25) - + if n == 0: return '0' elif n == 1: diff --git a/pytest.ini b/pytest.ini index 42660b6cdee8..c372f3404d1b 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,5 @@ [pytest] -testpaths = lib +testpaths = lib examples python_files = test_*.py markers = @@ -99,29 +99,29 @@ pep8ignore = doc/* E302 E501 tutorials/* E402 E501 - *examples/* E501 E402 - *examples/misc/table_demo.py E201 - *examples/images_contours_and_fields/tricontour_demo.py E201 - *examples/images_contours_and_fields/tripcolor_demo.py E201 - *examples/images_contours_and_fields/triplot_demo.py E201 - *examples/pyplots/align_ylabels.py E231 - *examples/pyplots/annotate_transform.py E228 E251 - *examples/pyplots/annotation_basic.py E231 - *examples/pyplots/annotation_polar.py E231 - *examples/pyplots/auto_subplots_adjust.py E231 E261 E302 W391 - *examples/pyplots/boxplot_demo_pyplot.py E231 - *examples/pyplots/compound_path_demo.py E231 - *examples/pyplots/fig_axes_customize_simple.py E261 - *examples/pyplots/pyplot_formatstr.py E231 - *examples/pyplots/pyplot_mathtext.py E231 - *examples/pyplots/pyplot_simple.py E231 - *examples/pyplots/pyplot_two_subplots.py E302 - *examples/pyplots/text_commands.py E231 - *examples/pyplots/text_layout.py E231 - *examples/pyplots/whats_new_1_subplot3d.py W391 - *examples/pyplots/whats_new_98_4_fancy.py E225 E261 E302 - *examples/pyplots/whats_new_98_4_fill_between.py E225 - *examples/pyplots/whats_new_98_4_legend.py E228 - *examples/pyplots/whats_new_99_axes_grid.py E225 E231 E302 E303 - *examples/pyplots/whats_new_99_spines.py E231 E261 - *examples/shapes_and_collections/artist_reference.py E203 + examples/* E501 E402 + examples/misc/table_demo.py E201 + examples/images_contours_and_fields/tricontour_demo.py E201 + examples/images_contours_and_fields/tripcolor_demo.py E201 + examples/images_contours_and_fields/triplot_demo.py E201 + examples/pyplots/align_ylabels.py E231 + examples/pyplots/annotate_transform.py E228 E251 + examples/pyplots/annotation_basic.py E231 + examples/pyplots/annotation_polar.py E231 + examples/pyplots/auto_subplots_adjust.py E231 E261 E302 W391 + examples/pyplots/boxplot_demo_pyplot.py E231 + examples/pyplots/compound_path_demo.py E231 + examples/pyplots/fig_axes_customize_simple.py E261 + examples/pyplots/pyplot_formatstr.py E231 + examples/pyplots/pyplot_mathtext.py E231 + examples/pyplots/pyplot_simple.py E231 + examples/pyplots/pyplot_two_subplots.py E302 + examples/pyplots/text_commands.py E231 + examples/pyplots/text_layout.py E231 + examples/pyplots/whats_new_1_subplot3d.py W391 + examples/pyplots/whats_new_98_4_fancy.py E225 E261 E302 + examples/pyplots/whats_new_98_4_fill_between.py E225 + examples/pyplots/whats_new_98_4_legend.py E228 + examples/pyplots/whats_new_99_axes_grid.py E225 E231 E302 E303 + examples/pyplots/whats_new_99_spines.py E231 E261 + examples/shapes_and_collections/artist_reference.py E203 From 43f19261665476de97143306ed32b803b46d375c Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 29 Jun 2018 15:15:12 +0100 Subject: [PATCH 2/2] Fix multiple imports --- examples/pyplots/whats_new_1_subplot3d.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/pyplots/whats_new_1_subplot3d.py b/examples/pyplots/whats_new_1_subplot3d.py index 5372ad10e0f1..0e69530deec4 100644 --- a/examples/pyplots/whats_new_1_subplot3d.py +++ b/examples/pyplots/whats_new_1_subplot3d.py @@ -45,7 +45,8 @@ # The use of the following functions, methods, classes and modules is shown # in this example: -import matplotlib, mpl_toolkits +import matplotlib +import mpl_toolkits matplotlib.figure.Figure.add_subplot mpl_toolkits.mplot3d.axes3d.Axes3D.plot_surface mpl_toolkits.mplot3d.axes3d.Axes3D.plot_wireframe