Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c06610a

Browse files
committed
FIX: cast max/min to scaled dtype
This fixes a future issue with '-' between bool being deprecated by numpy.
1 parent e5b9f7d commit c06610a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/matplotlib/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
367367
scaled_dtype = np.float32
368368
# old versions of numpy do not work with `np.nammin`
369369
# and `np.nanmax` as inputs
370-
a_min = np.ma.min(A)
371-
a_max = np.ma.max(A)
370+
a_min = np.ma.min(A).astype(scaled_dtype)
371+
a_max = np.ma.max(A).astype(scaled_dtype)
372372
# scale the input data to [.1, .9]. The Agg
373373
# interpolators clip to [0, 1] internally, use a
374374
# smaller input scale to identify which of the

lib/matplotlib/tests/test_image.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,3 +802,8 @@ def test_empty_imshow():
802802
def test_imshow_float128():
803803
fig, ax = plt.subplots()
804804
ax.imshow(np.zeros((3, 3), dtype=np.longdouble))
805+
806+
807+
def test_imshow_bool():
808+
fig, ax = plt.subplots()
809+
ax.imshow(np.array([[True, False], [False, True]], dtype=bool))

0 commit comments

Comments
 (0)