Skip to content

Clean up E265 in examples. #19626

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 1 commit into from
Mar 4, 2021
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
4 changes: 0 additions & 4 deletions examples/axes_grid1/demo_axes_grid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 3 additions & 3 deletions examples/axisartist/simple_axisline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions examples/color/named_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
10 changes: 5 additions & 5 deletions examples/event_handling/timers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 2 additions & 2 deletions examples/images_contours_and_fields/irregulardatagrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions examples/images_contours_and_fields/tricontour_smooth_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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')
Expand Down
20 changes: 10 additions & 10 deletions examples/images_contours_and_fields/trigradient_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions examples/mplot3d/subplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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')

Expand Down
8 changes: 4 additions & 4 deletions examples/mplot3d/trisurf3d_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -43,9 +43,9 @@
ax.set_zlim(-1, 1)


#============
# ===========
# Second plot
#============
# ===========

# Make parameter spaces radii and angles.
n_angles = 36
Expand Down
4 changes: 2 additions & 2 deletions examples/pie_and_polar_charts/nested_pie.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 0 additions & 4 deletions examples/pyplots/whats_new_1_subplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

from matplotlib import cm
#from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/specialty_plots/topographic_hillshading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand All @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions examples/text_labels_and_annotations/annotation_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 0 additions & 1 deletion examples/text_labels_and_annotations/line_with_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions examples/user_interfaces/embedding_in_wx2_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
4 changes: 2 additions & 2 deletions examples/user_interfaces/embedding_in_wx5_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down