8000 Use shorter function names (min, max, abs, conj). · danielballan/matplotlib@3d00576 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d00576

Browse files
committed
Use shorter function names (min, max, abs, conj).
1 parent 1504540 commit 3d00576

20 files changed

+72
-90
lines changed

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/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/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))

examples/pylab_examples/axes_demo.py

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

1515
# the main axes is subplot(111) by default
1616
plt.plot(t, s)
17-
plt.axis([0, 1, 1.1*np.amin(s), 2*np.amax(s)])
17+
plt.axis([0, 1, 1.1 * np.min(s), 2 * np.max(s)])
1818
plt.xlabel('time (s)')
1919
plt.ylabel('current (nA)')
2020
plt.title('Gaussian colored noise')

examples/pylab_examples/layer_images.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ def func3(x, y):
2323
# for the images their apparent extent could be different due to
2424
# interpolation edge effects
2525

26-
27-
xmin, xmax, ymin, ymax = np.amin(x), np.amax(x), np.amin(y), np.amax(y)
28-
extent = xmin, xmax, ymin, ymax
26+
extent = np.min(x), np.max(x), np.min(y), np.max(y)
2927
fig = plt.figure(frameon=False)
3028

3129
Z1 = np.add.outer(range(8), range(8)) % 2 # chessboard

examples/pylab_examples/line_collection2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
# We need to set the plot limits, they will not autoscale
1515
ax = plt.axes()
16-
ax.set_xlim((np.amin(x), np.amax(x)))
17-
ax.set_ylim((np.amin(np.amin(ys)), np.amax(np.amax(ys))))
16+
ax.set_xlim(np.min(x), np.max(x))
17+
ax.set_ylim(np.min(ys), np.max(ys))
1818

1919
# colors is sequence of rgba tuples
2020
# linestyle is a string or dash tuple. Legal string values are

examples/pylab_examples/multi_image.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from matplotlib.pyplot import figure, show, axes, sci
88
from matplotlib import cm, colors
99
from matplotlib.font_manager import FontProperties
10-
from numpy import amin, amax, ravel
11-
from numpy.random import rand
10+
import numpy as np
1211

1312
Nr = 3
1413
Nc = 2
@@ -37,12 +36,12 @@
3736
a.set_xticklabels([])
3837
# Make some fake data with a range that varies
3938
# somewhat from one plot to the next.
40-
data = ((1 + i + j)/10.0)*rand(10, 20)*1e-6
41-
dd = ravel(data)
39+
data = ((1 + i + j) / 10) * np.random.rand(10, 20) * 1e-6
40+
dd = data.ravel()
4241
# Manually find the min and max of all colors for
4342
# use in setting the color scale.
44-
vmin = min(vmin, amin(dd))
45-
vmax = max(vmax, amax(dd))
43+
vmin = min(vmin, np.min(dd))
44+
vmax = max(vmax, np.max(dd))
4645
images.append(a.imshow(data, cmap=cmap))
4746

4847
ax.append(a)

examples/pylab_examples/quadmesh_demo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
Z = (Z - Z.min()) / (Z.max() - Z.min())
2222

2323
# The color array can include masked values:
24-
Zm = ma.masked_where(np.fabs(Qz) < 0.5*np.amax(Qz), Z)
25-
24+
Zm = ma.masked_where(np.abs(Qz) < 0.5 * np.max(Qz), Z)
2625

2726
fig = figure()
2827
ax = fig.add_subplot(121)

examples/pylab_examples/vline_hline_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
def f(t):
1111
s1 = np.sin(2 * np.pi * t)
1212
e1 = np.exp(-t)
13-
return np.absolute((s1 * e1)) + .05
13+
return np.abs(s1 * e1) + .05
1414

1515
t = np.arange(0.0, 5.0, 0.1)
1616
s = f(t)

0 commit comments

Comments
 (0)
0