8000 Make clip and force vmin and vmax to float64 · matplotlib/matplotlib@2dd9d54 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2dd9d54

Browse files
committed
Make clip and force vmin and vmax to float64
1 parent 4529d6f commit 2dd9d54

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/matplotlib/image.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,16 +402,22 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
402402
# a norm first would be good, but ruins the interpolation
403403
# of over numbers.
404404
if self.norm.vmin is not None and self.norm.vmax is not None:
405-
dv = self.norm.vmax - self.norm.vmin
405+
dv = (np.float64(self.norm.vmax) -
406+
np.float64(self.norm.vmin))
406407
vmid = self.norm.vmin + dv / 2
407408
newmin = vmid - dv * 1.e7
408-
if newmin > a_min:
409-
A_scaled[A_scaled < newmin ] = newmin
409+
if newmin < a_min:
410+
newmin = None
411+
else:
410412
a_min = np.float64(newmin)
411413
newmax = vmid + dv * 1.e7
412-
if newmax < a_max:
413-
A_scaled[A_scaled > newmax] = newmax
414+
if newmax > a_max:
415+
newmax = None
416+
else:
414417
a_max = np.float64(newmax)
418+
if newmax is not None or newmin is not None:
419+
A_scaled = np.clip(A_scaled, newmin, newmax)
420+
415421
A_scaled -= a_min
416422
# a_min and a_max might be ndarray subclasses so use
417423
# asscalar to ensure they are scalars to avoid errors

0 commit comments

Comments
 (0)
0