FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

FIX: image respect norm limits w/ None by jklymak · Pull Request #11047 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
35 changes: 18 additions & 17 deletions lib/matplotlib/image.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -390,26 +390,27 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
# float64's ability to represent changes. Applying
# a norm first would be good, but ruins the interpolation
# of over numbers.
if self.norm.vmin is not None and self.norm.vmax is not None:
dv = (np.float64(self.norm.vmax) -
np.float64(self.norm.vmin))
vmid = self.norm.vmin + dv / 2
newmin = vmid - dv * 1.e7
if newmin < a_min:
newmin = None
else:
a_min = np.float64(newmin)
newmax = vmid + dv * 1.e7
if newmax > a_max:
newmax = None
else:
a_max = np.float64(newmax)
if newmax is not None or newmin is not None:
A_scaled = np.clip(A_scaled, newmin, newmax)
self.norm.autoscale_None(A)
dv = (np.float64(self.norm.vmax) -
np.float64(self.norm.vmin))
vmid = self.norm.vmin + dv / 2
fact = 1e7 if scaled_dtype == np.float64 else 1e4
newmin = vmid - dv * fact
if newmin < a_min:
newmin = None
else:
a_min = np.float64(newmin)
newmax = vmid + dv * fact
if newmax > a_max:
newmax = None
else:
a_max = np.float64(newmax)
if newmax is not None or newmin is not None:
A_scaled = np.clip(A_scaled, newmin, newmax)

A_scaled -= a_min
# a_min and a_max might be ndarray subclasses so use
# asscalar to ensure they are scalars to avoid errors
# asscalar to avoid errors
a_min = np.asscalar(a_min.astype(scaled_dtype))
a_max = np.asscalar(a_max.astype(scaled_dtype))

Expand Down

Back | FazBrowse Home | New Git URL