diff --git a/examples/color/color_by_yvalue.py b/examples/color/color_by_yvalue.py index 4c9e61a8326f..79d18ab0919b 100644 --- a/examples/color/color_by_yvalue.py +++ b/examples/color/color_by_yvalue.py @@ -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. @@ -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) diff --git a/examples/mplot3d/mixed_subplots.py b/examples/mplot3d/mixed_subplots.py index 0a13715aad1b..a325171e3c8d 100644 --- a/examples/mplot3d/mixed_subplots.py +++ b/examples/mplot3d/mixed_subplots.py @@ -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 diff --git a/examples/showcase/mandelbrot.py b/examples/showcase/mandelbrot.py index b31e9e34ca81..873e23ef3eb1 100644 --- a/examples/showcase/mandelbrot.py +++ b/examples/showcase/mandelbrot.py @@ -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 diff --git a/lib/matplotlib/tests/test_triangulation.py b/lib/matplotlib/tests/test_triangulation.py index 2ab0d27ac867..4c11fa95a4af 100644 --- a/lib/matplotlib/tests/test_triangulation.py +++ b/lib/matplotlib/tests/test_triangulation.py @@ -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) diff --git a/lib/matplotlib/tri/tritools.py b/lib/matplotlib/tri/tritools.py index d97bbd56734a..66c00a28b7b6 100644 --- a/lib/matplotlib/tri/tritools.py +++ b/lib/matplotlib/tri/tritools.py @@ -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 diff --git a/lib/mpl_toolkits/tests/test_mplot3d.py b/lib/mpl_toolkits/tests/test_mplot3d.py index d3ef8ce3ecc0..a1d3fd6653e9 100644 --- a/lib/mpl_toolkits/tests/test_mplot3d.py +++ b/lib/mpl_toolkits/tests/test_mplot3d.py @@ -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)