From 657cee991e503e146242ee327954adbf790962d8 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 3 Mar 2021 00:54:36 -0500 Subject: [PATCH] Clean up E265 in examples. --- examples/axes_grid1/demo_axes_grid2.py | 4 ---- examples/axisartist/simple_axisline.py | 6 +++--- examples/color/named_colors.py | 6 +++--- examples/event_handling/timers.py | 10 +++++----- .../irregulardatagrid.py | 4 ++-- .../tricontour_smooth_delaunay.py | 16 +++++++-------- .../tricontour_smooth_user.py | 16 +++++++-------- .../trigradient_demo.py | 20 +++++++++---------- examples/mplot3d/subplot3d.py | 10 +++++----- examples/mplot3d/trisurf3d_2.py | 8 ++++---- examples/pie_and_polar_charts/nested_pie.py | 4 ++-- examples/pyplots/whats_new_1_subplot3d.py | 4 ---- .../topographic_hillshading.py | 4 ++-- .../annotation_demo.py | 5 +---- .../line_with_text.py | 1 - .../embedding_in_wx2_sgskip.py | 4 ++-- .../embedding_in_wx5_sgskip.py | 4 ++-- 17 files changed, 57 insertions(+), 69 deletions(-) diff --git a/examples/axes_grid1/demo_axes_grid2.py b/examples/axes_grid1/demo_axes_grid2.py index b18648186c5d..488460921471 100644 --- a/examples/axes_grid1/demo_axes_grid2.py +++ b/examples/axes_grid1/demo_axes_grid2.py @@ -58,10 +58,6 @@ def add_inner_title(ax, title, loc, **kwargs): for ax, z in zip(grid, ZS): ax.cax.toggle_label(True) - #axis = ax.cax.axis[ax.cax.orientation] - #axis.label.set_text("counts s$^{-1}$") - #axis.label.set_size(10) - #axis.major_ticklabels.set_size(6) grid[0].set_xticks([-2, 0]) grid[0].set_yticks([-2, 0, 2]) diff --git a/examples/axisartist/simple_axisline.py b/examples/axisartist/simple_axisline.py index 7623763f1ea7..da0aad34a28a 100644 --- a/examples/axisartist/simple_axisline.py +++ b/examples/axisartist/simple_axisline.py @@ -24,9 +24,9 @@ ax.set_ylim(-2, 4) ax.set_xlabel("Label X") ax.set_ylabel("Label Y") -# or -#ax.axis["bottom"].label.set_text("Label X") -#ax.axis["left"].label.set_text("Label Y") +# Or: +# ax.axis["bottom"].label.set_text("Label X") +# ax.axis["left"].label.set_text("Label Y") # make new (right-side) yaxis, but with some offset ax.axis["right2"] = ax.new_fixed_axis(loc="right", offset=(20, 0)) diff --git a/examples/color/named_colors.py b/examples/color/named_colors.py index a1cbf1a92eca..2f64112263c2 100644 --- a/examples/color/named_colors.py +++ b/examples/color/named_colors.py @@ -78,12 +78,12 @@ def plot_colortable(colors, title, sort_colors=True, emptycols=0): plot_colortable(mcolors.TABLEAU_COLORS, "Tableau Palette", sort_colors=False, emptycols=2) -#sphinx_gallery_thumbnail_number = 3 +# sphinx_gallery_thumbnail_number = 3 plot_colortable(mcolors.CSS4_COLORS, "CSS Colors") # Optionally plot the XKCD colors (Caution: will produce large figure) -#xkcd_fig = plot_colortable(mcolors.XKCD_COLORS, "XKCD Colors") -#xkcd_fig.savefig("XKCD_Colors.png") +# xkcd_fig = plot_colortable(mcolors.XKCD_COLORS, "XKCD Colors") +# xkcd_fig.savefig("XKCD_Colors.png") plt.show() diff --git a/examples/event_handling/timers.py b/examples/event_handling/timers.py index 4db7fe40bdc3..ac064b261bcb 100644 --- a/examples/event_handling/timers.py +++ b/examples/event_handling/timers.py @@ -26,10 +26,10 @@ def update_title(axes): timer.add_callback(update_title, ax) timer.start() -# Or could start the timer on first figure draw -#def start_timer(event): -# timer.start() -# fig.canvas.mpl_disconnect(drawid) -#drawid = fig.canvas.mpl_connect('draw_event', start_timer) +# Or could start the timer on first figure draw: +# def start_timer(event): +# timer.start() +# fig.canvas.mpl_disconnect(drawid) +# drawid = fig.canvas.mpl_connect('draw_event', start_timer) plt.show() diff --git a/examples/images_contours_and_fields/irregulardatagrid.py b/examples/images_contours_and_fields/irregulardatagrid.py index d49a47ee06d9..523273a920f9 100644 --- a/examples/images_contours_and_fields/irregulardatagrid.py +++ b/examples/images_contours_and_fields/irregulardatagrid.py @@ -52,8 +52,8 @@ # Note that scipy.interpolate provides means to interpolate data on a grid # as well. The following would be an alternative to the four lines above: -#from scipy.interpolate import griddata -#zi = griddata((x, y), z, (xi[None, :], yi[:, None]), method='linear') +# from scipy.interpolate import griddata +# zi = griddata((x, y), z, (xi[None, :], yi[:, None]), method='linear') ax1.contour(xi, yi, zi, levels=14, linewidths=0.5, colors='k') cntr1 = ax1.contourf(xi, yi, zi, levels=14, cmap="RdBu_r") diff --git a/examples/images_contours_and_fields/tricontour_smooth_delaunay.py b/examples/images_contours_and_fields/tricontour_smooth_delaunay.py index ab187ef8eac4..0e1b3b17ae54 100644 --- a/examples/images_contours_and_fields/tricontour_smooth_delaunay.py +++ b/examples/images_contours_and_fields/tricontour_smooth_delaunay.py @@ -29,9 +29,9 @@ import numpy as np -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Analytical test function -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- def experiment_res(x, y): """An analytic function representing experiment results.""" x = 2 * x @@ -44,9 +44,9 @@ def experiment_res(x, y): 2 * (x**2 + y**2)) return (np.max(z) - z) / (np.max(z) - np.min(z)) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Generating the initial data test points and triangulation for the demo -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # User parameters for data test points # Number of test data points, tested from 3 to 5000 for subdiv=3 @@ -83,9 +83,9 @@ def experiment_res(x, y): tri.set_mask(mask_init) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Improving the triangulation before high-res plots: removing flat triangles -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # masking badly shaped triangles at the border of the triangular mesh. mask = TriAnalyzer(tri).get_flat_tri_mask(min_circle_ratio) tri.set_mask(mask) @@ -102,9 +102,9 @@ def experiment_res(x, y): flat_tri.set_mask(~mask) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Now the plots -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # User options for plots plot_tri = True # plot of base triangulation plot_masked_tri = True # plot of excessively flat excluded triangles diff --git a/examples/images_contours_and_fields/tricontour_smooth_user.py b/examples/images_contours_and_fields/tricontour_smooth_user.py index ef82ff8ff4b2..699cf0ce0d95 100644 --- a/examples/images_contours_and_fields/tricontour_smooth_user.py +++ b/examples/images_contours_and_fields/tricontour_smooth_user.py @@ -12,9 +12,9 @@ import numpy as np -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Analytical test function -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- def function_z(x, y): r1 = np.sqrt((0.5 - x)**2 + (0.5 - y)**2) theta1 = np.arctan2(0.5 - x, 0.5 - y) @@ -25,9 +25,9 @@ def function_z(x, y): 0.7 * (x**2 + y**2)) return (np.max(z) - z) / (np.max(z) - np.min(z)) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Creating a Triangulation -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # First create the x and y coordinates of the points. n_angles = 20 n_radii = 10 @@ -52,15 +52,15 @@ def function_z(x, y): y[triang.triangles].mean(axis=1)) < min_radius) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Refine data -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- refiner = tri.UniformTriRefiner(triang) tri_refi, z_test_refi = refiner.refine_field(z, subdiv=3) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Plot the triangulation and the high-res iso-contours -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- fig, ax = plt.subplots() ax.set_aspect('equal') ax.triplot(triang, lw=0.5, color='white') diff --git a/examples/images_contours_and_fields/trigradient_demo.py b/examples/images_contours_and_fields/trigradient_demo.py index d1120ebf59b5..73e518c6ee17 100644 --- a/examples/images_contours_and_fields/trigradient_demo.py +++ b/examples/images_contours_and_fields/trigradient_demo.py @@ -13,9 +13,9 @@ import numpy as np -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Electrical potential of a dipole -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- def dipole_potential(x, y): """The electric dipole potential V, at position *x*, *y*.""" r_sq = x**2 + y**2 @@ -24,9 +24,9 @@ def dipole_potential(x, y): return (np.max(z) - z) / (np.max(z) - np.min(z)) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Creating a Triangulation -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # First create the x and y coordinates of the points. n_angles = 30 n_radii = 10 @@ -50,23 +50,23 @@ def dipole_potential(x, y): y[triang.triangles].mean(axis=1)) < min_radius) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Refine data - interpolates the electrical potential V -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- refiner = UniformTriRefiner(triang) tri_refi, z_test_refi = refiner.refine_field(V, subdiv=3) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Computes the electrical field (Ex, Ey) as gradient of electrical potential -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- tci = CubicTriInterpolator(triang, -V) # Gradient requested here at the mesh nodes but could be anywhere else: (Ex, Ey) = tci.gradient(triang.x, triang.y) E_norm = np.sqrt(Ex**2 + Ey**2) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Plot the triangulation, the potential iso-contours and the vector field -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- fig, ax = plt.subplots() ax.set_aspect('equal') # Enforce the margins, and enlarge them to give room for the vectors. diff --git a/examples/mplot3d/subplot3d.py b/examples/mplot3d/subplot3d.py index 633817601c1b..782b22164c3d 100644 --- a/examples/mplot3d/subplot3d.py +++ b/examples/mplot3d/subplot3d.py @@ -16,9 +16,9 @@ # set up a figure twice as wide as it is tall fig = plt.figure(figsize=plt.figaspect(0.5)) -#=============== -# First subplot -#=============== +# ============= +# First subplot +# ============= # set up the axes for the first plot ax = fig.add_subplot(1, 2, 1, projection='3d') @@ -33,9 +33,9 @@ ax.set_zlim(-1.01, 1.01) fig.colorbar(surf, shrink=0.5, aspect=10) -#=============== +# ============== # Second subplot -#=============== +# ============== # set up the axes for the second plot ax = fig.add_subplot(1, 2, 2, projection='3d') diff --git a/examples/mplot3d/trisurf3d_2.py b/examples/mplot3d/trisurf3d_2.py index 88011e1148d4..728698b7af69 100644 --- a/examples/mplot3d/trisurf3d_2.py +++ b/examples/mplot3d/trisurf3d_2.py @@ -17,9 +17,9 @@ fig = plt.figure(figsize=plt.figaspect(0.5)) -#============ +# ========== # First plot -#============ +# ========== # Make a mesh in the space of parameterisation variables u and v u = np.linspace(0, 2.0 * np.pi, endpoint=True, num=50) @@ -43,9 +43,9 @@ ax.set_zlim(-1, 1) -#============ +# =========== # Second plot -#============ +# =========== # Make parameter spaces radii and angles. n_angles = 36 diff --git a/examples/pie_and_polar_charts/nested_pie.py b/examples/pie_and_polar_charts/nested_pie.py index b0c921351b8e..f861e97b33c4 100644 --- a/examples/pie_and_polar_charts/nested_pie.py +++ b/examples/pie_and_polar_charts/nested_pie.py @@ -56,9 +56,9 @@ size = 0.3 vals = np.array([[60., 32.], [37., 40.], [29., 10.]]) -#normalize vals to 2 pi +# Normalize vals to 2 pi valsnorm = vals/np.sum(vals)*2*np.pi -#obtain the ordinates of the bar edges +# Obtain the ordinates of the bar edges valsleft = np.cumsum(np.append(0, valsnorm.flatten()[:-1])).reshape(vals.shape) cmap = plt.get_cmap("tab20c") diff --git a/examples/pyplots/whats_new_1_subplot3d.py b/examples/pyplots/whats_new_1_subplot3d.py index 6e304c2a94e2..bd8399e60b7b 100644 --- a/examples/pyplots/whats_new_1_subplot3d.py +++ b/examples/pyplots/whats_new_1_subplot3d.py @@ -7,7 +7,6 @@ """ from matplotlib import cm -#from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter import matplotlib.pyplot as plt import numpy as np @@ -23,9 +22,6 @@ linewidth=0, antialiased=False) ax.set_zlim3d(-1.01, 1.01) -#ax.zaxis.set_major_locator(LinearLocator(10)) -#ax.zaxis.set_major_formatter(FormatStrFormatter('%.03f')) - fig.colorbar(surf, shrink=0.5, aspect=5) from mpl_toolkits.mplot3d.axes3d import get_test_data diff --git a/examples/specialty_plots/topographic_hillshading.py b/examples/specialty_plots/topographic_hillshading.py index 1b97a8a57808..68e9b3bb45a8 100644 --- a/examples/specialty_plots/topographic_hillshading.py +++ b/examples/specialty_plots/topographic_hillshading.py @@ -24,7 +24,7 @@ dem = get_sample_data('jacksboro_fault_dem.npz', np_load=True) z = dem['elevation'] -#-- Optional dx and dy for accurate vertical exaggeration --------------------- +# -- Optional dx and dy for accurate vertical exaggeration -------------------- # If you need topographically accurate vertical exaggeration, or you don't want # to guess at what *vert_exag* should be, you'll need to specify the cellsize # of the grid (i.e. the *dx* and *dy* parameters). Otherwise, any *vert_exag* @@ -36,7 +36,7 @@ dx, dy = dem['dx'], dem['dy'] dy = 111200 * dy dx = 111200 * dx * np.cos(np.radians(dem['ymin'])) -#------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- # Shade from the northwest, with the sun 45 degrees from horizontal ls = LightSource(azdeg=315, altdeg=45) diff --git a/examples/text_labels_and_annotations/annotation_demo.py b/examples/text_labels_and_annotations/annotation_demo.py index f04460b7698b..d4f2a39527a7 100644 --- a/examples/text_labels_and_annotations/annotation_demo.py +++ b/examples/text_labels_and_annotations/annotation_demo.py @@ -338,11 +338,8 @@ # It is also possible to generate draggable annotations an1 = ax1.annotate('Drag me 1', xy=(.5, .7), xycoords='data', - #xytext=(.5, .7), textcoords='data', ha="center", va="center", - bbox=bbox_args, - #arrowprops=arrow_args - ) + bbox=bbox_args) an2 = ax1.annotate('Drag me 2', xy=(.5, .5), xycoords=an1, xytext=(.5, .3), textcoords='axes fraction', diff --git a/examples/text_labels_and_annotations/line_with_text.py b/examples/text_labels_and_annotations/line_with_text.py index ffacab587f92..ee437c6110c0 100644 --- a/examples/text_labels_and_annotations/line_with_text.py +++ b/examples/text_labels_and_annotations/line_with_text.py @@ -55,7 +55,6 @@ def draw(self, renderer): fig, ax = plt.subplots() x, y = np.random.rand(2, 20) line = MyLine(x, y, mfc='red', ms=12, label='line label') -#line.text.set_text('line label') line.text.set_color('red') line.text.set_fontsize(16) diff --git a/examples/user_interfaces/embedding_in_wx2_sgskip.py b/examples/user_interfaces/embedding_in_wx2_sgskip.py index 19580517e9e1..fcebeeee8cd6 100644 --- a/examples/user_interfaces/embedding_in_wx2_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx2_sgskip.py @@ -47,8 +47,8 @@ def add_toolbar(self): self.toolbar.update() -# alternatively you could use -#class App(wx.App): +# Alternatively you could use: +# class App(wx.App): class App(WIT.InspectableApp): def OnInit(self): """Create the main window and insert the custom frame.""" diff --git a/examples/user_interfaces/embedding_in_wx5_sgskip.py b/examples/user_interfaces/embedding_in_wx5_sgskip.py index 2a97089697bc..26453537b094 100644 --- a/examples/user_interfaces/embedding_in_wx5_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx5_sgskip.py @@ -44,8 +44,8 @@ def add(self, name="plot"): def demo(): - # alternatively you could use - #app = wx.App() + # Alternatively you could use: + # app = wx.App() # InspectableApp is a great debug tool, see: # http://wiki.wxpython.org/Widget%20Inspection%20Tool app = wit.InspectableApp()