From 958e60389d0115bdc444b46754d3ed704f684517 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 fdb4294b9696..32e282f6f563 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -98,7 +98,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 3ea0cb70d3e1..58a28c8f689a 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -421,9 +421,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)