From 939ebbe9d985088ce6919858200726296566e87a Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 12 Oct 2018 21:08:32 +0200 Subject: [PATCH] Backport PR #12478: 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 82969ed18cb7..d005e59947f1 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -91,7 +91,7 @@ def _sanitize_extrema(ex): if ex is None: return ex try: - ret = np.asscalar(ex) + ret = ex.item() except AttributeError: ret = float(ex) return ret diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index a41428a5f345..a547f1b62a43 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 = 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)