Skip to content

Fix various flake8 indent problems. #14204

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
May 13, 2019
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
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ignore =
# Normal default
E121,E123,E126,E226,E24,E704,W503,W504,
# Additional ignores:
E111, E114, E115, E116, E122, E124, E125, E127, E128, E129, E131,
E122, E124, E125, E127, E128, E129, E131,
E265, E266,
E305, E306,
E722, E741,
Expand Down
25 changes: 14 additions & 11 deletions examples/images_contours_and_fields/tricontour_smooth_delaunay.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,23 @@ def experiment_res(x, y):
# Generating the initial data test points and triangulation for the demo
#-----------------------------------------------------------------------------
# User parameters for data test points
n_test = 200 # Number of test data points, tested from 3 to 5000 for subdiv=3

subdiv = 3 # Number of recursive subdivisions of the initial mesh for smooth
# plots. Values >3 might result in a very high number of triangles
# for the refine mesh: new triangles numbering = (4**subdiv)*ntri
# Number of test data points, tested from 3 to 5000 for subdiv=3
n_test = 200

init_mask_frac = 0.0 # Float > 0. adjusting the proportion of
# (invalid) initial triangles which will be masked
# out. Enter 0 for no mask.
# Number of recursive subdivisions of the initial mesh for smooth plots.
# Values >3 might result in a very high number of triangles for the refine
# mesh: new triangles numbering = (4**subdiv)*ntri
subdiv = 3

min_circle_ratio = .01 # Minimum circle ratio - border triangles with circle
# ratio below this will be masked if they touch a
# border. Suggested value 0.01; use -1 to keep
# all triangles.
# Float > 0. adjusting the proportion of (invalid) initial triangles which will
# be masked out. Enter 0 for no mask.
init_mask_frac = 0.0

# Minimum circle ratio - border triangles with circle ratio below this will be
# masked if they touch a border. Suggested value 0.01; use -1 to keep all
# triangles.
min_circle_ratio = .01

# Random points
random_gen = np.random.RandomState(seed=19680801)
Expand Down
3 changes: 1 addition & 2 deletions examples/misc/multipage_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
x = np.arange(0, 5, 0.1)
plt.plot(x, np.sin(x), 'b-')
plt.title('Page Two')
pdf.attach_note("plot of sin(x)") # you can add a pdf note to
# attach metadata to a page
pdf.attach_note("plot of sin(x)") # attach metadata (as pdf note) to page
pdf.savefig()
plt.close()

Expand Down
33 changes: 17 additions & 16 deletions examples/pyplots/auto_subplots_adjust.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,31 @@
or `~.Figure.constrained_layout`; this example shows how one could customize
the subplot parameter adjustment.
"""

import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms

fig, ax = plt.subplots()
ax.plot(range(10))
ax.set_yticks((2,5,7))
labels = ax.set_yticklabels(('really, really, really', 'long', 'labels'))

def on_draw(event):
bboxes = []
for label in labels:
bbox = label.get_window_extent()
# the figure transform goes from relative coords->pixels and we
# want the inverse of that
bboxi = bbox.inverse_transformed(fig.transFigure)
bboxes.append(bboxi)

# this is the bbox that bounds all the bboxes, again in relative
# figure coords
bbox = mtransforms.Bbox.union(bboxes)
if fig.subplotpars.left < bbox.width:
# we need to move it over
fig.subplots_adjust(left=1.1*bbox.width) # pad a little
fig.canvas.draw()
return False
bboxes = []
for label in labels:
bbox = label.get_window_extent()
# the figure transform goes from relative coords->pixels and we
# want the inverse of that
bboxi = bbox.inverse_transformed(fig.transFigure)
bboxes.append(bboxi)

# this is the bbox that bounds all the bboxes, again in relative
# figure coords
bbox = mtransforms.Bbox.union(bboxes)
if fig.subplotpars.left < bbox.width:
# we need to move it over
fig.subplots_adjust(left=1.1*bbox.width) # pad a little
fig.canvas.draw()

fig.canvas.mpl_connect('draw_event', on_draw)

Expand Down
7 changes: 4 additions & 3 deletions examples/user_interfaces/embedding_in_tk_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ def on_key_press(event):


def _quit():
root.quit() # stops mainloop
root.destroy() # this is necessary on Windows to prevent
# Fatal Python Error: PyEval_RestoreThread: NULL tstate
root.quit() # Stops mainloop.
# The following is necessary on Windows to prevent
# Fatal Python Error: PyEval_RestoreThread: NULL tstate
root.destroy()


button = tkinter.Button(master=root, text="Quit", command=_quit)
Expand Down
6 changes: 2 additions & 4 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2630,8 +2630,7 @@ def __init__(self, canvas):
self.canvas = canvas
canvas.toolbar = self
self._nav_stack = cbook.Stack()
self._xypress = None # the location and axis info at the time
# of the press
self._xypress = None # location and axis info at the time of the press
self._idPress = None
self._idRelease = None
self._active = None
Expand All @@ -2644,8 +2643,7 @@ def __init__(self, canvas):
self._ids_zoom = []
self._zoom_mode = None

self._button_pressed = None # determined by the button pressed
# at start
self._button_pressed = None # determined by button pressed at start

self.mode = '' # a mode string for the status bar
self.set_history_buttons()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_cairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _append_path(ctx, path, transform, clip=None):
if code == Path.MOVETO:
ctx.move_to(*points)
elif code == Path.CLOSEPOLY:
ctx.close_path()
ctx.close_path()
elif code == Path.LINETO:
ctx.line_to(*points)
elif code == Path.CURVE3:
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,7 @@ def __init__(self, filename, metadata=None):

self.paths = []

self.pageAnnotations = [] # A list of annotations for the
# current page
self.pageAnnotations = [] # A list of annotations for the current page

# The PDF spec recommends to include every procset
procsets = [Name(x)
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,7 @@ class ListedColormap(Colormap):
the list will be extended by repetition.
"""
def __init__(self, colors, name='from_list', N=None):
self.monochrome = False # True only if all colors in map are
# identical; needed for contouring.
self.monochrome = False # Are all colors identical? (for contour.py)
if N is None:
self.colors = colors
N = len(colors)
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,8 @@ def __init__(self, ax, *args,
self.extend = extend
self.antialiased = antialiased
if self.antialiased is None and self.filled:
self.antialiased = False # eliminate artifacts; we are not
# stroking the boundaries.
# Eliminate artifacts; we are not stroking the boundaries.
self.antialiased = False
# The default for line contours will be taken from the
# LineCollection default, which uses :rc:`lines.antialiased`.

Expand Down
29 changes: 13 additions & 16 deletions lib/matplotlib/quiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,10 @@ def __init__(self, Q, X, Y, U, label,
def on_dpi_change(fig):
self_weakref = weak_self()
if self_weakref is not None:
self_weakref.labelsep = (self_weakref._labelsep_inches*fig.dpi)
self_weakref._initialized = False # simple brute force update
# works because _init is
# called at the start of
# draw.
self_weakref.labelsep = self_weakref._labelsep_inches * fig.dpi
# simple brute force update works because _init is called at
# the start of draw.
self_weakref._initialized = False

self._cid = Q.ax.figure.callbacks.connect('dpi_changed',
on_dpi_change)
Expand Down Expand Up @@ -464,12 +463,11 @@ def __init__(self, ax, *args,
def on_dpi_change(fig):
self_weakref = weak_self()
if self_weakref is not None:
self_weakref._new_UV = True # vertices depend on width, span
# which in turn depend on dpi
self_weakref._initialized = False # simple brute force update
# works because _init is
# called at the start of
# draw.
# vertices depend on width, span which in turn depend on dpi
self_weakref._new_UV = True
# simple brute force update works because _init is called at
# the start of draw.
self_weakref._initialized = False

self._cid = self.ax.figure.callbacks.connect('dpi_changed',
on_dpi_change)
Expand Down Expand Up @@ -712,12 +710,11 @@ def _h_arrows(self, length):
if self.pivot == 'middle':
X -= 0.5 * X[:, 3, np.newaxis]
elif self.pivot == 'tip':
X = X - X[:, 3, np.newaxis] # numpy bug? using -= does not
# work here unless we multiply
# by a float first, as with 'mid'.
# numpy bug? using -= does not work here unless we multiply by a
# float first, as with 'mid'.
X = X - X[:, 3, np.newaxis]
elif self.pivot != 'tail':
raise ValueError(("Quiver.pivot must have value in {{'middle', "
"'tip', 'tail'}} not {0}").format(self.pivot))
cbook._check_in_list(["middle", "tip", "tail"], pivot=self.pivot)

tooshort = length < self.minlength
if tooshort.any():
Expand Down
6 changes: 2 additions & 4 deletions lib/matplotlib/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ def limit_range_for_scale(self, vmin, vmax, minpos):
Limit the domain to positive values.
"""
if not np.isfinite(minpos):
minpos = 1e-300 # This value should rarely if ever
# end up with a visible effect.
minpos = 1e-300 # Should rarely (if ever) have a visible effect.

return (minpos if vmin <= 0 else vmin,
minpos if vmax <= 0 else vmax)
Expand Down Expand Up @@ -708,8 +707,7 @@ def limit_range_for_scale(self, vmin, vmax, minpos):
Limit the domain to values between 0 and 1 (excluded).
"""
if not np.isfinite(minpos):
minpos = 1e-7 # This value should rarely if ever
# end up with a visible effect.
minpos = 1e-7 # Should rarely (if ever) have a visible effect.
return (minpos if vmin <= 0 else vmin,
1 - minpos if vmax >= 1 else vmax)

Expand Down
5 changes: 3 additions & 2 deletions lib/matplotlib/tight_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,9 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
ncols_list = []
ax_bbox_list = []

subplot_dict = {} # Multiple axes can share same subplot_interface (e.g.,
# axes_grid1); thus we need to join them together.
# Multiple axes can share same subplot_interface (e.g., axes_grid1); thus
# we need to join them together.
subplot_dict = {}

subplotspec_list2 = []

Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axes_grid1/mpl_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def __init__(self, axes):
def __getitem__(self, k):
if isinstance(k, tuple):
r = SimpleChainedObjects(
# super() within a list comprehension needs explicit args.
[super(Axes.AxisDict, self).__getitem__(k1) for k1 in k])
# super() within a list comprehension needs explicit args
return r
elif isinstance(k, slice):
if k.start is None and k.stop is None and k.step is None:
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axisartist/floating_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ def _update_grid(self, x1, y1, x2, y2):
grid_info["lat_lines"] = lat_lines

lon_lines, lat_lines = grid_finder._get_raw_grid_lines(
extremes[:2], extremes[2:], *extremes)
# lon_min, lon_max, lat_min, lat_max)
extremes[:2], extremes[2:], *extremes)

grid_info["lon_lines0"] = lon_lines
grid_info["lat_lines0"] = lat_lines
Expand Down