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

Skip to content

Replace use of np.<ufunc> by operators (</&/|). #13386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/color/color_by_yvalue.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
================
Color By y-value
Color by y-value
================

Use masked arrays to plot a line with different colors by y-value.
Expand All @@ -14,10 +14,9 @@
upper = 0.77
lower = -0.77


supper = np.ma.masked_where(s < upper, s)
slower = np.ma.masked_where(s > lower, s)
smiddle = np.ma.masked_where(np.logical_or(s < lower, s > upper), s)
smiddle = np.ma.masked_where((s < lower) | (s > upper), s)

fig, ax = plt.subplots()
ax.plot(t, smiddle, t, slower, t, supper)
Expand Down
4 changes: 1 addition & 3 deletions examples/mplot3d/mixed_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@


def f(t):
s1 = np.cos(2*np.pi*t)
e1 = np.exp(-t)
return np.multiply(s1, e1)
return np.cos(2*np.pi*t) * np.exp(-t)


# Set up a figure twice as tall as it is wide
Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/mandelbrot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def mandelbrot_set(xmin, xmax, ymin, ymax, xn, yn, maxiter, horizon=2.0):
N = np.zeros_like(C, dtype=int)
Z = np.zeros_like(C)
for n in range(maxiter):
I = np.less(abs(Z), horizon)
I = abs(Z) < horizon
N[I] = n
Z[I] = Z[I]**2 + C[I]
N[N == maxiter-1] = 0
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ def test_qhull_triangle_orientation():
# github issue 4437.
xi = np.linspace(-2, 2, 100)
x, y = map(np.ravel, np.meshgrid(xi, xi))
w = np.logical_and(x > y - 1, np.logical_and(x < -1.95, y > -1.2))
w = (x > y - 1) & (x < -1.95) & (y > -1.2)
x, y = x[w], y[w]
theta = np.radians(25)
x1 = x*np.cos(theta) - y*np.sin(theta)
Expand Down
7 changes: 3 additions & 4 deletions lib/matplotlib/tri/tritools.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,11 @@ def get_flat_tri_mask(self, min_circle_ratio=0.01, rescale=True):
while nadd != 0:
# The active wavefront is the triangles from the border (unmasked
# but with a least 1 neighbor equal to -1
wavefront = ((np.min(valid_neighbors, axis=1) == -1)
& ~current_mask)
wavefront = (np.min(valid_neighbors, axis=1) == -1) & ~current_mask
# The element from the active wavefront will be masked if their
# circle ratio is bad.
added_mask = np.logical_and(wavefront, mask_bad_ratio)
current_mask = (added_mask | current_mask)
added_mask = wavefront & mask_bad_ratio
current_mask = added_mask | current_mask
nadd = np.sum(added_mask)

# now we have to update the tables valid_neighbors
Expand Down
4 changes: 1 addition & 3 deletions lib/mpl_toolkits/tests/test_mplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ def test_lines3d():
pytest.param('svg', marks=pytest.mark.xfail(strict=False))])
def test_mixedsubplots():
def f(t):
s1 = np.cos(2*np.pi*t)
e1 = np.exp(-t)
return np.multiply(s1, e1)
return np.cos(2*np.pi*t) * np.exp(-t)

t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)
Expand Down