Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit665cf51

Browse files
authored
Merge pull request#13020 from anntzer/proj3dmod
Deprecate proj3d.mod.
2 parentsb6e8c19 +114209a commit665cf51

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

‎lib/matplotlib/quiver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,10 +983,10 @@ def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50):
983983
mag=half* (mag/half+0.5).astype(int)
984984

985985
num_flags=np.floor(mag/flag).astype(int)
986-
mag=np.mod(mag,flag)
986+
mag=mag%flag
987987

988988
num_barb=np.floor(mag/full).astype(int)
989-
mag=np.mod(mag,full)
989+
mag=mag%full
990990

991991
half_flag=mag>=half
992992
empty_flag=~(half_flag| (num_flags>0)| (num_barb>0))

‎lib/matplotlib/tri/triinterpolate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ def compute_geom_weights(self):
11351135
alpha2=np.arctan2(p2[:,1]-p0[:,1],p2[:,0]-p0[:,0])
11361136
# In the below formula we could take modulo 2. but
11371137
# modulo 1. is safer regarding round-off errors (flat triangles).
1138-
angle=np.abs(np.mod((alpha2-alpha1)/np.pi,1.))
1138+
angle=np.abs(((alpha2-alpha1)/np.pi)%1)
11391139
# Weight proportional to angle up np.pi/2; null weight for
11401140
# degenerated cases 0 and np.pi (note that `angle` is normalized
11411141
# by np.pi).

‎lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ def get_proj(self):
10271027

10281028
self.eye=E
10291029
self.vvec=R-E
1030-
self.vvec=self.vvec/proj3d._mod(self.vvec)
1030+
self.vvec=self.vvec/np.linalg.norm(self.vvec)
10311031

10321032
ifabs(relev)>np.pi/2:
10331033
# upside down
@@ -1762,9 +1762,9 @@ def _shade_colors(self, color, normals, lightsource=None):
17621762
# chosen for backwards-compatibility
17631763
lightsource=LightSource(azdeg=225,altdeg=19.4712)
17641764

1765-
shade=np.array([np.dot(n/proj3d._mod(n),lightsource.direction)
1766-
ifproj3d._mod(n)elsenp.nan
1767-
forninnormals])
1765+
withnp.errstate(invalid="ignore"):
1766+
shade= ((normals/np.linalg.norm(normals,axis=1,keepdims=True))
1767+
@lightsource.direction)
17681768
mask=~np.isnan(shade)
17691769

17701770
ifmask.any():

‎lib/mpl_toolkits/mplot3d/proj3d.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# 3dproj.py
2-
#
31
"""
42
Various transforms used for by the 3D code
53
"""
4+
65
importnumpyasnp
76
importnumpy.linalgaslinalg
87

@@ -79,15 +78,10 @@ def line2d_seg_dist(p1, p2, p0):
7978
return_line2d_seg_dist(p1,p2,p0)
8079

8180

82-
def_mod(v):
83-
"""3d vector length"""
84-
returnnp.sqrt(v[0]**2+v[1]**2+v[2]**2)
85-
86-
87-
@cbook.deprecated("3.1")
81+
@cbook.deprecated("3.1",alternative="np.linalg.norm")
8882
defmod(v):
8983
"""3d vector length"""
90-
return_mod(v)
84+
returnnp.sqrt(v[0]**2+v[1]**2+v[2]**2)
9185

9286

9387
defworld_transformation(xmin,xmax,
@@ -103,9 +97,9 @@ def world_transformation(xmin, xmax,
10397
defview_transformation(E,R,V):
10498
n= (E-R)
10599
## new
106-
# n /=mod(n)
100+
# n /=np.linalg.norm(n)
107101
# u = np.cross(V,n)
108-
# u /=mod(u)
102+
# u /=np.linalg.norm(u)
109103
# v = np.cross(n,u)
110104
# Mr = np.diag([1.]*4)
111105
# Mt = np.diag([1.]*4)
@@ -114,9 +108,9 @@ def view_transformation(E, R, V):
114108
## end new
115109

116110
## old
117-
n=n/_mod(n)
111+
n=n/np.linalg.norm(n)
118112
u=np.cross(V,n)
119-
u=u/_mod(u)
113+
u=u/np.linalg.norm(u)
120114
v=np.cross(n,u)
121115
Mr= [[u[0],u[1],u[2],0],
122116
[v[0],v[1],v[2],0],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp