diff --git a/lib/matplotlib/quiver.py b/lib/matplotlib/quiver.py index b64a58b24527..2355ac60537d 100644 --- a/lib/matplotlib/quiver.py +++ b/lib/matplotlib/quiver.py @@ -983,10 +983,10 @@ def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50): mag = half * (mag / half + 0.5).astype(int) num_flags = np.floor(mag / flag).astype(int) - mag = np.mod(mag, flag) + mag = mag % flag num_barb = np.floor(mag / full).astype(int) - mag = np.mod(mag, full) + mag = mag % full half_flag = mag >= half empty_flag = ~(half_flag | (num_flags > 0) | (num_barb > 0)) diff --git a/lib/matplotlib/tri/triinterpolate.py b/lib/matplotlib/tri/triinterpolate.py index ed0813746e76..37b960e85137 100644 --- a/lib/matplotlib/tri/triinterpolate.py +++ b/lib/matplotlib/tri/triinterpolate.py @@ -1135,7 +1135,7 @@ def compute_geom_weights(self): alpha2 = np.arctan2(p2[:, 1]-p0[:, 1], p2[:, 0]-p0[:, 0]) # In the below formula we could take modulo 2. but # modulo 1. is safer regarding round-off errors (flat triangles). - angle = np.abs(np.mod((alpha2-alpha1) / np.pi, 1.)) + angle = np.abs(((alpha2-alpha1) / np.pi) % 1) # Weight proportional to angle up np.pi/2; null weight for # degenerated cases 0 and np.pi (note that `angle` is normalized # by np.pi). diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 468b3aa4cc0e..dd31670fd58e 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1027,7 +1027,7 @@ def get_proj(self): self.eye = E self.vvec = R - E - self.vvec = self.vvec / proj3d._mod(self.vvec) + self.vvec = self.vvec / np.linalg.norm(self.vvec) if abs(relev) > np.pi/2: # upside down @@ -1762,9 +1762,9 @@ def _shade_colors(self, color, normals, lightsource=None): # chosen for backwards-compatibility lightsource = LightSource(azdeg=225, altdeg=19.4712) - shade = np.array([np.dot(n / proj3d._mod(n), lightsource.direction) - if proj3d._mod(n) else np.nan - for n in normals]) + with np.errstate(invalid="ignore"): + shade = ((normals / np.linalg.norm(normals, axis=1, keepdims=True)) + @ lightsource.direction) mask = ~np.isnan(shade) if mask.any(): diff --git a/lib/mpl_toolkits/mplot3d/proj3d.py b/lib/mpl_toolkits/mplot3d/proj3d.py index 41a5df3845f8..e9081b9a6e51 100644 --- a/lib/mpl_toolkits/mplot3d/proj3d.py +++ b/lib/mpl_toolkits/mplot3d/proj3d.py @@ -1,8 +1,7 @@ -# 3dproj.py -# """ Various transforms used for by the 3D code """ + import numpy as np import numpy.linalg as linalg @@ -79,15 +78,10 @@ def line2d_seg_dist(p1, p2, p0): return _line2d_seg_dist(p1, p2, p0) -def _mod(v): - """3d vector length""" - return np.sqrt(v[0]**2+v[1]**2+v[2]**2) - - -@cbook.deprecated("3.1") +@cbook.deprecated("3.1", alternative="np.linalg.norm") def mod(v): """3d vector length""" - return _mod(v) + return np.sqrt(v[0]**2+v[1]**2+v[2]**2) def world_transformation(xmin, xmax, @@ -103,9 +97,9 @@ def world_transformation(xmin, xmax, def view_transformation(E, R, V): n = (E - R) ## new -# n /= mod(n) +# n /= np.linalg.norm(n) # u = np.cross(V,n) -# u /= mod(u) +# u /= np.linalg.norm(u) # v = np.cross(n,u) # Mr = np.diag([1.]*4) # Mt = np.diag([1.]*4) @@ -114,9 +108,9 @@ def view_transformation(E, R, V): ## end new ## old - n = n / _mod(n) + n = n / np.linalg.norm(n) u = np.cross(V, n) - u = u / _mod(u) + u = u / np.linalg.norm(u) v = np.cross(n, u) Mr = [[u[0], u[1], u[2], 0], [v[0], v[1], v[2], 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