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

Commitfaf9684

Browse files
committed
Merge pull request#11047 from jklymak/fix-image-respect-norm-limits
FIX: image respect norm limits w/ NoneConflicts:lib/matplotlib/image.py - keep changes backported from master. Looks like conflict was due to some white-space clean up done on master.
1 parenteb489f6 commitfaf9684

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

‎lib/matplotlib/image.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -401,26 +401,27 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
401401
# float64's ability to represent changes. Applying
402402
# a norm first would be good, but ruins the interpolation
403403
# of over numbers.
404-
ifself.norm.vminisnotNoneandself.norm.vmaxisnotNone:
405-
dv= (np.float64(self.norm.vmax)-
406-
np.float64(self.norm.vmin))
407-
vmid=self.norm.vmin+dv/2
408-
newmin=vmid-dv*1.e7
409-
ifnewmin<a_min:
410-
newmin=None
411-
else:
412-
a_min=np.float64(newmin)
413-
newmax=vmid+dv*1.e7
414-
ifnewmax>a_max:
415-
newmax=None
416-
else:
417-
a_max=np.float64(newmax)
418-
ifnewmaxisnotNoneornewminisnotNone:
419-
A_scaled=np.clip(A_scaled,newmin,newmax)
404+
self.norm.autoscale_None(A)
405+
dv= (np.float64(self.norm.vmax)-
406+
np.float64(self.norm.vmin))
407+
vmid=self.norm.vmin+dv/2
408+
fact=1e7ifscaled_dtype==np.float64else1e4
409+
newmin=vmid-dv*fact
410+
ifnewmin<a_min:
411+
newmin=None
412+
else:
413+
a_min=np.float64(newmin)
414+
newmax=vmid+dv*fact
415+
ifnewmax>a_max:
416+
newmax=None
417+
else:
418+
a_max=np.float64(newmax)
419+
ifnewmaxisnotNoneornewminisnotNone:
420+
A_scaled=np.clip(A_scaled,newmin,newmax)
420421

421422
A_scaled-=a_min
422423
# a_min and a_max might be ndarray subclasses so use
423-
# asscalar toensure they are scalars toavoid errors
424+
# asscalar to avoid errors
424425
a_min=np.asscalar(a_min.astype(scaled_dtype))
425426
a_max=np.asscalar(a_max.astype(scaled_dtype))
426427

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp