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

Skip to content

Commit de302f5

Browse files
committed
Call min/max directly on generator or two args.
1 parent 2ce3b61 commit de302f5

14 files changed

Lines changed: 59 additions & 71 deletions

File tree

doc/utils/pylab_names.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@
4646

4747
print()
4848
funcs, docs = zip(*modd[mod])
49-
maxfunc = max([len(f) for f in funcs])
50-
maxdoc = max(40, max([len(d) for d in docs]) )
51-
border = ' '.join(['='*maxfunc, '='*maxdoc])
49+
maxfunc = max(len(f) for f in funcs)
50+
maxdoc = max(40, max(len(d) for d in docs))
51+
border = '=' * maxfunc + ' ' + '=' * maxdoc
5252
print(border)
53-
print(' '.join(['symbol'.ljust(maxfunc), 'description'.ljust(maxdoc)]))
53+
print('{:<{}} {:<{}}'.format('symbol', maxfunc, 'description', maxdoc))
5454
print(border)
5555
for func, doc in modd[mod]:
56-
row = ' '.join([func.ljust(maxfunc), doc.ljust(maxfunc)])
57-
print(row)
58-
56+
print('{:<{}} {:<{}}'.format(func, maxfunc, doc, maxdoc))
5957
print(border)
6058
print()
61-
#break

examples/axes_grid1/scatter_hist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
# now determine nice limits by hand:
3232
binwidth = 0.25
33-
xymax = np.max([np.max(np.fabs(x)), np.max(np.fabs(y))])
33+
xymax = max(np.max(np.abs(x)), np.max(np.abs(y)))
3434
lim = (int(xymax/binwidth) + 1)*binwidth
3535

3636
bins = np.arange(-lim, lim + binwidth, binwidth)

examples/pylab_examples/scatter_hist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
# now determine nice limits by hand:
3939
binwidth = 0.25
40-
xymax = np.max([np.max(np.fabs(x)), np.max(np.fabs(y))])
40+
xymax = max(np.max(np.abs(x)), np.max(np.abs(y)))
4141
lim = (int(xymax/binwidth) + 1) * binwidth
4242

4343
axScatter.set_xlim((-lim, lim))

examples/widgets/menu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def __init__(self, fig, menuitems):
126126
self.menuitems = menuitems
127127
self.numitems = len(menuitems)
128128

129-
maxw = max([item.labelwidth for item in menuitems])
130-
maxh = max([item.labelheight for item in menuitems])
129+
maxw = max(item.labelwidth for item in menuitems)
130+
maxh = max(item.labelheight for item in menuitems)
131131

132132
totalh = self.numitems*maxh + (self.numitems + 1)*2*MenuItem.pady
133133

lib/matplotlib/artist.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,12 +1278,11 @@ def pprint_setters_rest(self, prop=None, leadingspace=2):
12781278

12791279
########
12801280
names = [self.aliased_name_rest(prop, target)
1281-
for prop, target
1282-
in attrs]
1281+
for prop, target in attrs]
12831282
accepts = [self.get_valid_values(prop) for prop, target in attrs]
12841283

1285-
col0_len = max([len(n) for n in names])
1286-
col1_len = max([len(a) for a in accepts])
1284+
col0_len = max(len(n) for n in names)
1285+
col1_len = max(len(a) for a in accepts)
12871286
table_formatstr = pad + '=' * col0_len + ' ' + '=' * col1_len
12881287

12891288
lines.append('')

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,17 +2162,17 @@ def make_iterable(x):
21622162

21632163
if adjust_xlim:
21642164
xmin, xmax = self.dataLim.intervalx
2165-
xmin = np.amin([w for w in width if w > 0])
2165+
xmin = np.min(w for w in width if w > 0)
21662166
if xerr is not None:
2167-
xmin = xmin - np.amax(xerr)
2167+
xmin = xmin - np.max(xerr)
21682168
xmin = max(xmin * 0.9, 1e-100)
21692169
self.dataLim.intervalx = (xmin, xmax)
21702170

21712171
if adjust_ylim:
21722172
ymin, ymax = self.dataLim.intervaly
2173-
ymin = np.amin([h for h in height if h > 0])
2173+
ymin = np.min(h for h in height if h > 0)
21742174
if yerr is not None:
2175-
ymin = ymin - np.amax(yerr)
2175+
ymin = ymin - np.max(yerr)
21762176
ymin = max(ymin * 0.9, 1e-100)
21772177
self.dataLim.intervaly = (ymin, ymax)
21782178
self.autoscale_view()

lib/matplotlib/mathtext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3183,8 +3183,8 @@ def overline(self, s, loc, toks):
31833183
def _auto_sized_delimiter(self, front, middle, back):
31843184
state = self.get_state()
31853185
if len(middle):
3186-
height = max([x.height for x in middle])
3187-
depth = max([x.depth for x in middle])
3186+
height = max(x.height for x in middle)
3187+
depth = max(x.depth for x in middle)
31883188
factor = None
31893189
else:
31903190
height = 0

lib/matplotlib/offsetbox.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ def _get_aligned_offsets(hd_list, height, align="baseline"):
119119
"""
120120

121121
if height is None:
122-
height = max([h for h, d in hd_list])
122+
height = max(h for h, d in hd_list)
123123

124124
if align == "baseline":
125-
height_descent = max([h - d for h, d in hd_list])
126-
descent = max([d for h, d in hd_list])
125+
height_descent = max(h - d for h, d in hd_list)
126+
descent = max(d for h, d in hd_list)
127127
height = height_descent + descent
128128
offsets = [0. for h, d in hd_list]
129129
elif align in ["left", "top"]:
@@ -465,8 +465,8 @@ def get_extent_offsets(self, renderer):
465465
return 2 * pad, 2 * pad, pad, pad, []
466466

467467
if self.height is None:
468-
height_descent = max([h - yd for w, h, xd, yd in whd_list])
469-
ydescent = max([yd for w, h, xd, yd in whd_list])
468+
height_descent = max(h - yd for w, h, xd, yd in whd_list)
469+
ydescent = max(yd for w, h, xd, yd in whd_list)
470470
height = height_descent + ydescent
471471
else:
472472
height = self.height - 2 * pad # width w/o pad

lib/matplotlib/patches.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ def _pprint_table(_table, leadingspace=2):
17731773
for column, cell in zip(columns, row):
17741774
column.append(cell)
17751775

1776-
col_len = [max([len(cell) for cell in column]) for column in columns]
1776+
col_len = [max(len(cell) for cell in column) for column in columns]
17771777

17781778
lines = []
17791779
table_formatstr = pad + ' '.join([('=' * cl) for cl in col_len])
@@ -2050,8 +2050,8 @@ def transmute(self, x0, y0, width, height, mutation_size):
20502050

20512051
# boundary of the padded box
20522052
x0, y0 = x0 - pad, y0 - pad,
2053-
return Path.circle((x0 + width/2., y0 + height/2.),
2054-
(max([width, height]) / 2.))
2053+
return Path.circle((x0 + width / 2, y0 + height / 2),
2054+
max(width, height) / 2)
20552055

20562056
_style_list["circle"] = Circle
20572057

lib/matplotlib/ticker.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,11 +1623,9 @@ def view_limits(self, vmin, vmax):
16231623
vmax += 1
16241624

16251625
if rcParams['axes.autolimit_mode'] == 'round_numbers':
1626-
exponent, remainder = _divmod(math.log10(vmax - vmin),
1627-
math.log10(max([self.numticks-1, 1])))
1628-
if remainder < 0.5:
1629-
exponent -= 1
1630-
scale = max([self.numticks-1, 1]) ** (-exponent)
1626+
exponent = round(math.log10(vmax - vmin)
1627+
/ math.log10(max(self.numticks - 1, 1))) - 1
1628+
scale = max(self.numticks - 1, 1) ** (-exponent)
16311629
vmin = math.floor(scale * vmin) / scale
16321630
vmax = math.ceil(scale * vmax) / scale
16331631

0 commit comments

Comments
 (0)