diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 6b8477f63018..5cd5c3f1026f 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -368,10 +368,14 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, scaled_dtype = A.dtype else: scaled_dtype = np.float32 - # old versions of numpy do not work with `np.nammin` - # and `np.nanmax` as inputs - a_min = np.ma.min(A).astype(scaled_dtype) - a_max = np.ma.max(A).astype(scaled_dtype) + + a_min = A.min() + if a_min is np.ma.masked: + a_min, a_max = 0, 1 # all masked, so values don't matter + else: + a_min = a_min.astype(scaled_dtype) + a_max = A.max().astype(scaled_dtype) + # scale the input data to [.1, .9]. The Agg # interpolators clip to [0, 1] internally, use a # smaller input scale to identify which of the diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 15c148f17cdb..0a16e97848f6 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -835,3 +835,13 @@ def test_imshow_deprecated_interd_warn(): with warnings.catch_warnings(record=True) as warns: getattr(im, k) assert len(warns) == 1 + + +def test_full_invalid(): + x = np.ones((10, 10)) + x[:] = np.nan + + f, ax = plt.subplots() + ax.imshow(x) + + f.canvas.draw()