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

Commitec50ff3

Browse files
authored
Merge pull request#26770 from meeseeksmachine/auto-backport-of-pr-26762-on-v3.8.x
2 parents4f15bdf +661c871 commitec50ff3

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

‎lib/matplotlib/cbook.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,8 @@ def safe_masked_invalid(x, copy=False):
734734
ifnotx.dtype.isnative:
735735
# If we have already made a copy, do the byteswap in place, else make a
736736
# copy with the byte order swapped.
737-
x=x.byteswap(inplace=copy).newbyteorder('N')# Swap to native order.
737+
# Swap to native order.
738+
x=x.byteswap(inplace=copy).view(x.dtype.newbyteorder('N'))
738739
try:
739740
xm=np.ma.masked_where(~(np.isfinite(x)),x,copy=False)
740741
exceptTypeError:

‎lib/matplotlib/colors.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,8 @@ def __call__(self, X, alpha=None, bytes=False):
726726

727727
xa=np.array(X,copy=True)
728728
ifnotxa.dtype.isnative:
729-
xa=xa.byteswap().newbyteorder()# Native byteorder is faster.
729+
# Native byteorder is faster.
730+
xa=xa.byteswap().view(xa.dtype.newbyteorder())
730731
ifxa.dtype.kind=="f":
731732
xa*=self.N
732733
# xa == 1 (== N after multiplication) is not out of range.
@@ -2161,7 +2162,7 @@ def rgb_to_hsv(arr):
21612162
out=np.zeros_like(arr)
21622163
arr_max=arr.max(-1)
21632164
ipos=arr_max>0
2164-
delta=arr.ptp(-1)
2165+
delta=np.ptp(arr,-1)
21652166
s=np.zeros_like(delta)
21662167
s[ipos]=delta[ipos]/arr_max[ipos]
21672168
ipos=delta>0

‎lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ def test_pcolormesh():
13271327
Qz=np.sin(Y)+np.sin(X)
13281328
Qx= (Qx+1.1)
13291329
Z=np.hypot(X,Y)/5
1330-
Z= (Z-Z.min())/Z.ptp()
1330+
Z= (Z-Z.min())/np.ptp(Z)
13311331

13321332
# The color array can include masked values:
13331333
Zm=ma.masked_where(np.abs(Qz)<0.5*np.max(Qz),Z)
@@ -1348,7 +1348,7 @@ def test_pcolormesh_small():
13481348
Qz=np.sin(Y)+np.sin(X)
13491349
Qx= (Qx+1.1)
13501350
Z=np.hypot(X,Y)/5
1351-
Z= (Z-Z.min())/Z.ptp()
1351+
Z= (Z-Z.min())/np.ptp(Z)
13521352
Zm=ma.masked_where(np.abs(Qz)<0.5*np.max(Qz),Z)
13531353
Zm2=ma.masked_where(Qz<-0.5*np.max(Qz),Z)
13541354

@@ -1378,7 +1378,7 @@ def test_pcolormesh_alpha():
13781378
Qx=X
13791379
Qy=Y+np.sin(X)
13801380
Z=np.hypot(X,Y)/5
1381-
Z= (Z-Z.min())/Z.ptp()
1381+
Z= (Z-Z.min())/np.ptp(Z)
13821382
vir=mpl.colormaps["viridis"].resampled(16)
13831383
# make another colormap with varying alpha
13841384
colors=vir(np.arange(16))

‎lib/matplotlib/tests/test_colors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def test_colormap_endian():
216216
a= [-0.5,0,0.5,1,1.5,np.nan]
217217
fordtin ["f2","f4","f8"]:
218218
anative=np.ma.masked_invalid(np.array(a,dtype=dt))
219-
aforeign=anative.byteswap().newbyteorder()
219+
aforeign=anative.byteswap().view(anative.dtype.newbyteorder())
220220
assert_array_equal(cmap(anative),cmap(aforeign))
221221

222222

@@ -1126,7 +1126,7 @@ def alternative_hillshade(azimuth, elev, z):
11261126

11271127
intensity=np.tensordot(normals,illum,axes=(2,0))
11281128
intensity-=intensity.min()
1129-
intensity/=intensity.ptp()
1129+
intensity/=np.ptp(intensity)
11301130
returnintensity
11311131

11321132
y,x=np.mgrid[5:0:-1, :5]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp