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

Appearance settings

Commit f6340d4

Browse filesBrowse files
committed
BUG: fix normalizing image data contained in np.ndarray subclass
1 parent 09eab5b commit f6340d4
Copy full SHA for f6340d4

File tree

2 files changed

+6
-6
lines changed
Filter options

2 files changed

+6
-6
lines changed

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,12 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
461461
vmid = np.float64(self.norm.vmin) + dv / 2
462462
fact = 1e7 if scaled_dtype == np.float64 else 1e4
463463
newmin = vmid - dv * fact
464-
if newmin < a_min:
464+
if newmin < np.float64(a_min):
465465
newmin = None
466466
else:
467467
a_min = np.float64(newmin)
468468
newmax = vmid + dv * fact
469-
if newmax > a_max:
469+
if newmax > np.float64(a_max):
470470
newmax = None
471471
else:
472472
a_max = np.float64(newmax)

‎lib/matplotlib/transforms.py

Copy file name to clipboardExpand all lines: lib/matplotlib/transforms.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,15 +2853,15 @@ def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
28532853
if (not np.isfinite(vmin)) or (not np.isfinite(vmax)):
28542854
return -expander, expander
28552855

2856+
# Expand vmin, vmax to float: if they were integer types, they can wrap
2857+
# around in abs (abs(np.int8(-128)) == -128) and vmax - vmin can overflow.
2858+
vmin, vmax = map(np.float64, (vmin, vmax))
2859+
28562860
swapped = False
28572861
if vmax < vmin:
28582862
vmin, vmax = vmax, vmin
28592863
swapped = True
28602864

2861-
# Expand vmin, vmax to float: if they were integer types, they can wrap
2862-
# around in abs (abs(np.int8(-128)) == -128) and vmax - vmin can overflow.
2863-
vmin, vmax = map(float, [vmin, vmax])
2864-
28652865
maxabsvalue = max(abs(vmin), abs(vmax))
28662866
if maxabsvalue < (1e6 / tiny) * np.finfo(float).tiny:
28672867
vmin = -expander

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.