Skip to content

Commit 409d8b7

Browse files
authored
Merge pull request #7547 from anntzer/additional-cleanups
Additional cleanups
2 parents 3612616 + f1b25e6 commit 409d8b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+271
-406
lines changed

boilerplate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def format_value(value):
317317
# A gensym-like facility in case some function takes an
318318
# argument named washold, ax, or ret
319319
washold, ret, ax = 'washold', 'ret', 'ax'
320-
bad = set(args) | set((varargs, varkw))
320+
bad = set(args) | {varargs, varkw}
321321
while washold in bad or ret in bad or ax in bad:
322322
washold = 'washold' + str(random.randrange(10 ** 12))
323323
ret = 'ret' + str(random.randrange(10 ** 12))

doc/sphinxext/gen_gallery.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,10 @@ def gen_gallery(app, doctree):
7676
# images we want to skip for the gallery because they are an unusual
7777
# size that doesn't layout well in a table, or because they may be
7878
# redundant with other images or uninteresting
79-
skips = set([
80-
'mathtext_examples',
81-
'matshow_02',
82-
'matshow_03',
83-
'matplotlib_icon',
84-
])
79+
skips = {'mathtext_examples',
80+
'matshow_02',
81+
'matshow_03',
82+
'matplotlib_icon'}
8583

8684
thumbnails = {}
8785
rows = []

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/api/collections_demo.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@
8989

9090
# 7-sided regular polygons
9191

92-
col = collections.RegularPolyCollection(7,
93-
sizes=np.fabs(xx) * 10.0, offsets=xyo,
94-
transOffset=ax3.transData)
92+
col = collections.RegularPolyCollection(
93+
7, sizes=np.abs(xx) * 10.0, offsets=xyo, transOffset=ax3.transData)
9594
trans = transforms.Affine2D().scale(fig.dpi / 72.0)
9695
col.set_transform(trans) # the points to pixels transform
9796
ax3.add_collection(col, autolim=True)
@@ -109,7 +108,7 @@
109108
offs = (0.1, 0.0)
110109

111110
yy = np.linspace(0, 2*np.pi, nverts)
112-
ym = np.amax(yy)
111+
ym = np.max(yy)
113112
xx = (0.2 + (ym - yy)/ym)**2 * np.cos(yy - 0.4)*0.5
114113
segs = []
115114
for i in range(ncurves):

examples/api/sankey_demo_old.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def sankey(ax,
3737
import matplotlib.patches as mpatches
3838
from matplotlib.path import Path
3939

40-
outs = np.absolute(outputs)
40+
outs = np.abs(outputs)
4141
outsigns = np.sign(outputs)
4242
outsigns[-1] = 0 # Last output
4343

44-
ins = np.absolute(inputs)
44+
ins = np.abs(inputs)
4545
insigns = np.sign(inputs)
4646
insigns[0] = 0 # First input
4747

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/axes_grid1/simple_axesgrid.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
from mpl_toolkits.axes_grid1 import ImageGrid
33
import numpy as np
44

5-
im = np.arange(100)
6-
im.shape = 10, 10
5+
im = np.arange(100).reshape((10, 10))
76

87
fig = plt.figure(1, (4., 4.))
98
grid = ImageGrid(fig, 111, # similar to subplot(111)

examples/event_handling/poly_editor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def get_ind_under_point(self, event):
7070
xy = np.asarray(self.poly.xy)
7171
xyt = self.poly.get_transform().transform(xy)
7272
xt, yt = xyt[:, 0], xyt[:, 1]
73-
d = np.sqrt((xt - event.x)**2 + (yt - event.y)**2)
74-
indseq = np.nonzero(np.equal(d, np.amin(d)))[0]
73+
d = np.hypot(xt - event.x, yt - event.y)
74+
indseq, = np.nonzero(d == d.min())
7575
ind = indseq[0]
7676

7777
if d[ind] >= self.epsilon:

examples/pylab_examples/agg_buffer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
l, b, w, h = agg.figure.bbox.bounds
2727
w, h = int(w), int(h)
2828

29-
X = np.fromstring(s, np.uint8)
30-
X.shape = h, w, 3
29+
X = np.fromstring(s, np.uint8).reshape((h, w, 3))
3130

3231
try:
3332
im = Image.fromstring("RGB", (w, h), s)

examples/pylab_examples/anscombe.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def fit(x):
2222
return 3 + 0.5*x
2323

2424

25-
xfit = np.array([np.amin(x), np.amax(x)])
25+
xfit = np.array([np.min(x), np.max(x)])
2626

2727
plt.subplot(221)
2828
plt.plot(x, y1, 'ks', xfit, fit(xfit), 'r-', lw=2)
@@ -43,8 +43,7 @@ def fit(x):
4343
plt.setp(plt.gca(), yticks=(4, 8, 12), xticks=(0, 10, 20))
4444

4545
plt.subplot(224)
46-
47-
xfit = np.array([np.amin(x4), np.amax(x4)])
46+
xfit = np.array([np.min(x4), np.max(x4)])
4847
plt.plot(x4, y4, 'ks', xfit, fit(xfit), 'r-', lw=2)
4948
plt.axis([2, 20, 2, 14])
5049
plt.setp(plt.gca(), yticklabels=[], yticks=(4, 8, 12), xticks=(0, 10, 20))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy