Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e87493

Browse files
authored
Merge pull request #16769 from QuLogic/style-fixes
Fix some small style issues
2 parents 0bf4f55 + 1270fc2 commit 8e87493

File tree

13 files changed

+35
-42
lines changed

13 files changed

+35
-42
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ignore =
44
# Normal default
55
E121,E123,E126,E226,E24,E704,W503,W504,
66
# Additional ignores:
7-
E122, E125, E127, E129, E131,
7+
E122, E127, E131,
88
E265, E266,
99
E305, E306,
1010
E722, E741,

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ def _init_tests():
11581158

11591159
from matplotlib import ft2font
11601160
if (ft2font.__freetype_version__ != LOCAL_FREETYPE_VERSION or
1161-
ft2font.__freetype_build_type__ != 'local'):
1161+
ft2font.__freetype_build_type__ != 'local'):
11621162
_log.warning(
11631163
f"Matplotlib is not built with the correct FreeType version to "
11641164
f"run tests. Rebuild without setting system_freetype=1 in "

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5825,7 +5825,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
58255825
# Transform from native to data coordinates?
58265826
t = collection._transform
58275827
if (not isinstance(t, mtransforms.Transform) and
5828-
hasattr(t, '_as_mpl_transform')):
5828+
hasattr(t, '_as_mpl_transform')):
58295829
t = t._as_mpl_transform(self.axes)
58305830

58315831
if t and any(t.contains_branch_seperately(self.transData)):
@@ -6057,7 +6057,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
60576057
# Transform from native to data coordinates?
60586058
t = collection._transform
60596059
if (not isinstance(t, mtransforms.Transform) and
6060-
hasattr(t, '_as_mpl_transform')):
6060+
hasattr(t, '_as_mpl_transform')):
60616061
t = t._as_mpl_transform(self.axes)
60626062

60636063
if t and any(t.contains_branch_seperately(self.transData)):
@@ -6209,7 +6209,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
62096209
dx = np.diff(x)
62106210
dy = np.diff(y)
62116211
if (np.ptp(dx) < 0.01 * abs(dx.mean()) and
6212-
np.ptp(dy) < 0.01 * abs(dy.mean())):
6212+
np.ptp(dy) < 0.01 * abs(dy.mean())):
62136213
style = "image"
62146214
else:
62156215
style = "pcolorimage"

lib/matplotlib/axes/_secondary_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def set_functions(self, functions):
189189
inverse.
190190
"""
191191
if (isinstance(functions, tuple) and len(functions) == 2 and
192-
callable(functions[0]) and callable(functions[1])):
192+
callable(functions[0]) and callable(functions[1])):
193193
# make an arbitrary convert from a two-tuple of functions
194194
# forward and inverse.
195195
self._functions = functions

lib/matplotlib/axis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323

2424
# This list is being used for compatibility with Axes.grid, which
2525
# allows all Line2D kwargs.
26-
_line_AI = martist.ArtistInspector(mlines.Line2D)
27-
_line_param_names = _line_AI.get_setters()
28-
_line_param_aliases = [list(d)[0] for d in _line_AI.aliasd.values()]
26+
_line_inspector = martist.ArtistInspector(mlines.Line2D)
27+
_line_param_names = _line_inspector.get_setters()
28+
_line_param_aliases = [list(d)[0] for d in _line_inspector.aliasd.values()]
2929
_gridline_param_names = ['grid_' + name
3030
for name in _line_param_names + _line_param_aliases]
3131

lib/matplotlib/backends/backend_wx.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,9 +1344,8 @@ def __init__(self, toolmanager, parent, style=wx.TB_HORIZONTAL):
13441344
self._toolitems = {}
13451345
self._groups = {}
13461346

1347-
def add_toolitem(
1348-
self, name, group, position, image_file, description, toggle):
1349-
1347+
def add_toolitem(self, name, group, position, image_file, description,
1348+
toggle):
13501349
before, group = self._add_to_group(group, name, position)
13511350
idx = self.GetToolPos(before.Id)
13521351
if image_file:

lib/matplotlib/collections.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def get_datalim(self, transData):
197197
transform = self.get_transform()
198198
transOffset = self.get_offset_transform()
199199
if (not self._offsetsNone and
200-
not transOffset.contains_branch(transData)):
200+
not transOffset.contains_branch(transData)):
201201
# if there are offsets but in some coords other than data,
202202
# then don't use them for autoscaling.
203203
return transforms.Bbox.null()
@@ -329,11 +329,11 @@ def draw(self, renderer):
329329
edgecolors = self.get_edgecolor()
330330
do_single_path_optimization = False
331331
if (len(paths) == 1 and len(trans) <= 1 and
332-
len(facecolors) == 1 and len(edgecolors) == 1 and
333-
len(self._linewidths) == 1 and
334-
all(ls[1] is None for ls in self._linestyles) and
335-
len(self._antialiaseds) == 1 and len(self._urls) == 1 and
336-
self.get_hatch() is None):
332+
len(facecolors) == 1 and len(edgecolors) == 1 and
333+
len(self._linewidths) == 1 and
334+
all(ls[1] is None for ls in self._linestyles) and
335+
len(self._antialiaseds) == 1 and len(self._urls) == 1 and
336+
self.get_hatch() is None):
337337
if len(trans):
338338
combined_transform = transforms.Affine2D(trans[0]) + transform
339339
else:

lib/matplotlib/font_manager.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -631,12 +631,8 @@ def __init__(self,
631631
if isinstance(family, str):
632632
# Treat family as a fontconfig pattern if it is the only
633633
# parameter provided.
634-
if (style is None and
635-
variant is None and
636-
weight is None and
637-
stretch is None and
638-
size is None and
639-
fname is None):
634+
if (style is None and variant is None and weight is None and
635+
stretch is None and size is None and fname is None):
640636
self.set_fontconfig_pattern(family)
641637
return
642638

lib/matplotlib/scale.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ def set_default_locators_and_formatters(self, axis):
109109
axis.set_major_formatter(ScalarFormatter())
110110
axis.set_minor_formatter(NullFormatter())
111111
# update the minor locator for x and y axis based on rcParams
112-
if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible']
113-
or axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']):
112+
if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or
113+
axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']):
114114
axis.set_minor_locator(AutoMinorLocator())
115115
else:
116116
axis.set_minor_locator(NullLocator())
@@ -194,8 +194,8 @@ def set_default_locators_and_formatters(self, axis):
194194
axis.set_major_formatter(ScalarFormatter())
195195
axis.set_minor_formatter(NullFormatter())
196196
# update the minor locator for x and y axis based on rcParams
197-
if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible']
198-
or axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']):
197+
if (axis.axis_name == 'x' and mpl.rcParams['xtick.minor.visible'] or
198+
axis.axis_name == 'y' and mpl.rcParams['ytick.minor.visible']):
199199
axis.set_minor_locator(AutoMinorLocator())
200200
else:
201201
axis.set_minor_locator(NullLocator())

lib/matplotlib/tests/test_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class BaseFilter:
101101
def get_pad(self, dpi):
102102
return 0
103103

104-
def process_image(padded_src, dpi):
104+
def process_image(self, padded_src, dpi):
105105
raise NotImplementedError("Should be overridden by subclasses")
106106

107107
def __call__(self, im, dpi):

lib/matplotlib/transforms.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ def _check(points):
228228
if isinstance(points, np.ma.MaskedArray):
229229
cbook._warn_external("Bbox bounds are a masked array.")
230230
points = np.asarray(points)
231-
if (points[1, 0] - points[0, 0] == 0 or
232-
points[1, 1] - points[0, 1] == 0):
231+
if any((points[1, :] - points[0, :]) == 0):
233232
cbook._warn_external("Singular Bbox.")
234233

235234
def frozen(self):
@@ -2170,8 +2169,8 @@ def blended_transform_factory(x_transform, y_transform):
21702169
A faster version of the blended transform is returned for the case
21712170
where both child transforms are affine.
21722171
"""
2173-
if (isinstance(x_transform, Affine2DBase)
2174-
and isinstance(y_transform, Affine2DBase)):
2172+
if (isinstance(x_transform, Affine2DBase) and
2173+
isinstance(y_transform, Affine2DBase)):
21752174
return BlendedAffine2D(x_transform, y_transform)
21762175
return BlendedGenericTransform(x_transform, y_transform)
21772176

@@ -2222,10 +2221,9 @@ def _invalidate_internal(self, value, invalidating_node):
22222221
# either:
22232222
# (a) the left hand transform is non affine
22242223
# (b) it is the left hand node which has triggered the invalidation
2225-
if value == Transform.INVALID_AFFINE \
2226-
and not self._b.is_affine \
2227-
and (not self._a.is_affine or invalidating_node is self._a):
2228-
2224+
if (value == Transform.INVALID_AFFINE and
2225+
not self._b.is_affine and
2226+
(not self._a.is_affine or invalidating_node is self._a)):
22292227
value = Transform.INVALID
22302228

22312229
Transform._invalidate_internal(self, value=value,
@@ -2566,7 +2564,7 @@ def _revalidate(self):
25662564
# only recompute if the invalidation includes the non_affine part of
25672565
# the transform
25682566
if (self._invalid & self.INVALID_NON_AFFINE == self.INVALID_NON_AFFINE
2569-
or self._transformed_path is None):
2567+
or self._transformed_path is None):
25702568
self._transformed_path = \
25712569
self._transform.transform_path_non_affine(self._path)
25722570
self._transformed_points = \

lib/mpl_toolkits/axes_grid1/inset_locator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,8 @@ def inset_axes(parent_axes, width, height, loc='upper right',
487487
if bbox_to_anchor is None:
488488
bbox_to_anchor = parent_axes.bbox
489489

490-
if isinstance(bbox_to_anchor, tuple) and \
491-
(isinstance(width, str) or isinstance(height, str)):
490+
if (isinstance(bbox_to_anchor, tuple) and
491+
(isinstance(width, str) or isinstance(height, str))):
492492
if len(bbox_to_anchor) != 4:
493493
raise ValueError("Using relative units for width or height "
494494
"requires to provide a 4-tuple or a "

tutorials/colors/colormap-manipulation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ def plot_examples(colormaps):
138138
# middle 0.5 of the colormap. However, we need to interpolate from a larger
139139
# colormap, otherwise the new colormap will have repeated values.
140140

141-
viridisBig = cm.get_cmap('viridis', 512)
142-
newcmp = ListedColormap(viridisBig(np.linspace(0.25, 0.75, 256)))
141+
viridis_big = cm.get_cmap('viridis', 512)
142+
newcmp = ListedColormap(viridis_big(np.linspace(0.25, 0.75, 256)))
143143
plot_examples([viridis, newcmp])
144144

145145
##############################################################################

0 commit comments

Comments
 (0)