Skip to content

Commit ac97e14

Browse files
authored
Merge pull request #11680 from anntzer/style
Boring style fixes.
2 parents 8b46f31 + a87445c commit ac97e14

File tree

21 files changed

+41
-45
lines changed

21 files changed

+41
-45
lines changed

examples/statistics/barchart_demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ def attach_ordinal(num):
7777
1 -> 1st
7878
56 -> 56th
7979
"""
80-
suffixes = dict((str(i), v) for i, v in
81-
enumerate(['th', 'st', 'nd', 'rd', 'th',
82-
'th', 'th', 'th', 'th', 'th']))
80+
suffixes = {str(i): v
81+
for i, v in enumerate(['th', 'st', 'nd', 'rd', 'th',
82+
'th', 'th', 'th', 'th', 'th'])}
8383

8484
v = str(num)
8585
# special case early teens
@@ -170,7 +170,7 @@ def plot_student_results(student, scores, cohort_size):
170170

171171
rankStr = attach_ordinal(width)
172172
# The bars aren't wide enough to print the ranking inside
173-
if (width < 5):
173+
if width < 5:
174174
# Shift the text to the right side of the right edge
175175
xloc = width + 1
176176
# Black against white background

examples/units/basic_units.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ def get_unit(self):
249249
class UnitResolver(object):
250250
def addition_rule(self, units):
251251
for unit_1, unit_2 in zip(units[:-1], units[1:]):
252-
if (unit_1 != unit_2):
252+
if unit_1 != unit_2:
253253
return NotImplemented
254254
return units[0]
255255

256256
def multiplication_rule(self, units):
257257
non_null = [u for u in units if u]
258-
if (len(non_null) > 1):
258+
if len(non_null) > 1:
259259
return NotImplemented
260260
return non_null[0]
261261

@@ -268,7 +268,7 @@ def multiplication_rule(self, units):
268268
'__rsub__': addition_rule}
269269

270270
def __call__(self, operation, units):
271-
if (operation not in self.op_dict):
271+
if operation not in self.op_dict:
272272
return NotImplemented
273273

274274
return self.op_dict[operation](self, units)

lib/matplotlib/backends/backend_ps.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,16 @@ def set_linedash(self, offset, seq, store=1):
266266
self.linedash = (offset, seq)
267267

268268
def set_font(self, fontname, fontsize, store=1):
269-
if rcParams['ps.useafm']: return
270-
if (fontname,fontsize) != (self.fontname,self.fontsize):
269+
if rcParams['ps.useafm']:
270+
return
271+
if (fontname, fontsize) != (self.fontname,self.fontsize):
271272
out = ("/%s findfont\n"
272273
"%1.3f scalefont\n"
273274
"setfont\n" % (fontname, fontsize))
274-
275275
self._pswriter.write(out)
276-
if store: self.fontname = fontname
277-
if store: self.fontsize = fontsize
276+
if store:
277+
self.fontname = fontname
278+
self.fontsize = fontsize
278279

279280
def create_hatch(self, hatch):
280281
sidelen = 72

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ def delete_masked_points(*args):
10951095
"""
10961096
if not len(args):
10971097
return ()
1098-
if isinstance(args[0], str) or not iterable(args[0]):
1098+
if is_scalar_or_string(args[0]):
10991099
raise ValueError("First argument must be a sequence")
11001100
nrecs = len(args[0])
11011101
margs = []

lib/matplotlib/collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ def set_verts(self, verts, closed=True):
964964

965965
def set_verts_and_codes(self, verts, codes):
966966
'''This allows one to initialize vertices with path codes.'''
967-
if (len(verts) != len(codes)):
967+
if len(verts) != len(codes):
968968
raise ValueError("'codes' must be a 1D list or array "
969969
"with the same length of 'verts'")
970970
self._paths = []

lib/matplotlib/figure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,9 @@ def suptitle(self, t, **kwargs):
737737
x = kwargs.pop('x', 0.5)
738738
y = kwargs.pop('y', 0.98)
739739

740-
if ('horizontalalignment' not in kwargs) and ('ha' not in kwargs):
740+
if 'horizontalalignment' not in kwargs and 'ha' not in kwargs:
741741
kwargs['horizontalalignment'] = 'center'
742-
if ('verticalalignment' not in kwargs) and ('va' not in kwargs):
742+
if 'verticalalignment' not in kwargs and 'va' not in kwargs:
743743
kwargs['verticalalignment'] = 'top'
744744

745745
if 'fontproperties' not in kwargs:

lib/matplotlib/gridspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def __init__(self, nrows, ncols, figure=None,
212212
width_ratios=width_ratios,
213213
height_ratios=height_ratios)
214214

215-
if (self.figure is None) or not self.figure.get_constrained_layout():
215+
if self.figure is None or not self.figure.get_constrained_layout():
216216
self._layoutbox = None
217217
else:
218218
self.figure.init_layoutbox()

lib/matplotlib/legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ def _get_legend_handles_labels(axs, legend_handler_map=None):
12421242

12431243
for handle in _get_legend_handles(axs, legend_handler_map):
12441244
label = handle.get_label()
1245-
if (label and not label.startswith('_')):
1245+
if label and not label.startswith('_'):
12461246
handles.append(handle)
12471247
labels.append(label)
12481248
return handles, labels

lib/matplotlib/lines.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -882,10 +882,7 @@ def get_markeredgewidth(self):
882882
return self._markeredgewidth
883883

884884
def _get_markerfacecolor(self, alt=False):
885-
if alt:
886-
fc = self._markerfacecoloralt
887-
else:
888-
fc = self._markerfacecolor
885+
fc = self._markerfacecoloralt if alt else self._markerfacecolor
889886
if cbook._str_lower_equal(fc, 'auto'):
890887
if self.get_fillstyle() == 'none':
891888
return 'none'

lib/matplotlib/patches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def __init__(self,
7171
self._hatch_color = colors.to_rgba(mpl.rcParams['hatch.color'])
7272
self._fill = True # needed for set_facecolor call
7373
if color is not None:
74-
if (edgecolor is not None or facecolor is not None):
74+
if edgecolor is not None or facecolor is not None:
7575
warnings.warn("Setting the 'color' property will override"
76-
"the edgecolor or facecolor properties. ")
76+
"the edgecolor or facecolor properties.")
7777
self.set_color(color)
7878
else:
7979
self.set_edgecolor(edgecolor)

0 commit comments

Comments
 (0)