From d0e3a946a8ec5a462811504c12b0ba3e190c3ec6 Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Wed, 10 Oct 2018 11:53:06 -0500 Subject: [PATCH 1/2] MAINT: numpy deprecates asscalar in 1.16 --- lib/matplotlib/colors.py | 2 +- lib/matplotlib/image.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index bf49e34397dc..49c6e5cd89e4 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -107,7 +107,7 @@ def _sanitize_extrema(ex): if ex is None: return ex try: - ret = np.asscalar(ex) + ret = np.ndarray.item(ex) except AttributeError: ret = float(ex) return ret diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index fe22bffc0e3f..44ac8c92cfec 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -411,9 +411,9 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, A_scaled -= a_min # a_min and a_max might be ndarray subclasses so use - # asscalar to avoid errors - a_min = np.asscalar(a_min.astype(scaled_dtype)) - a_max = np.asscalar(a_max.astype(scaled_dtype)) + # item to avoid errors + a_min = np.ndarray.item(a_min.astype(scaled_dtype)) + a_max = np.ndarray.item(a_max.astype(scaled_dtype)) if a_min != a_max: A_scaled /= ((a_max - a_min) / 0.8) From 73c22bc7e5ecd40a5a446e17e55f50500873fbe9 Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Wed, 10 Oct 2018 12:03:27 -0500 Subject: [PATCH 2/2] MAINT Use attribute access so errors are caught --- lib/matplotlib/colors.py | 2 +- lib/matplotlib/image.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 49c6e5cd89e4..a06bee6fc070 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -107,7 +107,7 @@ def _sanitize_extrema(ex): if ex is None: return ex try: - ret = np.ndarray.item(ex) + ret = ex.item() except AttributeError: ret = float(ex) return ret diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 44ac8c92cfec..54a670288ebc 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -412,8 +412,8 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, A_scaled -= a_min # a_min and a_max might be ndarray subclasses so use # item to avoid errors - a_min = np.ndarray.item(a_min.astype(scaled_dtype)) - a_max = np.ndarray.item(a_max.astype(scaled_dtype)) + a_min = a_min.astype(scaled_dtype).item() + a_max = a_max.astype(scaled_dtype).item() if a_min != a_max: A_scaled /= ((a_max - a_min) / 0.8)