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

Skip to content

Commit c29f81e

Browse files
authored
Merge pull request #13386 from anntzer/operator
Replace use of np.<ufunc> by operators (</&/|).
2 parents f949caa + 1e2c2f1 commit c29f81e

File tree

6 files changed

+9
-15
lines changed

6 files changed

+9
-15
lines changed

examples/color/color_by_yvalue.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
================
3-
Color By y-value
3+
Color by y-value
44
================
55
66
Use masked arrays to plot a line with different colors by y-value.
@@ -14,10 +14,9 @@
1414
upper = 0.77
1515
lower = -0.77
1616

17-
1817
supper = np.ma.masked_where(s < upper, s)
1918
slower = np.ma.masked_where(s > lower, s)
20-
smiddle = np.ma.masked_where(np.logical_or(s < lower, s > upper), s)
19+
smiddle = np.ma.masked_where((s < lower) | (s > upper), s)
2120

2221
fig, ax = plt.subplots()
2322
ax.plot(t, smiddle, t, slower, t, supper)

examples/mplot3d/mixed_subplots.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414

1515
def f(t):
16-
s1 = np.cos(2*np.pi*t)
17-
e1 = np.exp(-t)
18-
return np.multiply(s1, e1)
16+
return np.cos(2*np.pi*t) * np.exp(-t)
1917

2018

2119
# Set up a figure twice as tall as it is wide

examples/showcase/mandelbrot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def mandelbrot_set(xmin, xmax, ymin, ymax, xn, yn, maxiter, horizon=2.0):
2020
N = np.zeros_like(C, dtype=int)
2121
Z = np.zeros_like(C)
2222
for n in range(maxiter):
23-
I = np.less(abs(Z), horizon)
23+
I = abs(Z) < horizon
2424
N[I] = n
2525
Z[I] = Z[I]**2 + C[I]
2626
N[N == maxiter-1] = 0

lib/matplotlib/tests/test_triangulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ def test_qhull_triangle_orientation():
10001000
# github issue 4437.
10011001
xi = np.linspace(-2, 2, 100)
10021002
x, y = map(np.ravel, np.meshgrid(xi, xi))
1003-
w = np.logical_and(x > y - 1, np.logical_and(x < -1.95, y > -1.2))
1003+
w = (x > y - 1) & (x < -1.95) & (y > -1.2)
10041004
x, y = x[w], y[w]
10051005
theta = np.radians(25)
10061006
x1 = x*np.cos(theta) - y*np.sin(theta)

lib/matplotlib/tri/tritools.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,11 @@ def get_flat_tri_mask(self, min_circle_ratio=0.01, rescale=True):
180180
while nadd != 0:
181181
# The active wavefront is the triangles from the border (unmasked
182182
# but with a least 1 neighbor equal to -1
183-
wavefront = ((np.min(valid_neighbors, axis=1) == -1)
184-
& ~current_mask)
183+
wavefront = (np.min(valid_neighbors, axis=1) == -1) & ~current_mask
185184
# The element from the active wavefront will be masked if their
186185
# circle ratio is bad.
187-
added_mask = np.logical_and(wavefront, mask_bad_ratio)
188-
current_mask = (added_mask | current_mask)
186+
added_mask = wavefront & mask_bad_ratio
187+
current_mask = added_mask | current_mask
189188
nadd = np.sum(added_mask)
190189

191190
# now we have to update the tables valid_neighbors

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ def test_lines3d():
139139
pytest.param('svg', marks=pytest.mark.xfail(strict=False))])
140140
def test_mixedsubplots():
141141
def f(t):
142-
s1 = np.cos(2*np.pi*t)
143-
e1 = np.exp(-t)
144-
return np.multiply(s1, e1)
142+
return np.cos(2*np.pi*t) * np.exp(-t)
145143

146144
t1 = np.arange(0.0, 5.0, 0.1)
147145
t2 = np.arange(0.0, 5.0, 0.02)

0 commit comments

Comments
 (0)