From 6c2b9fa68e9c2c48d972ef2b41c1fba5c0ba0524 Mon Sep 17 00:00:00 2001 From: lvr44 Date: Sat, 10 Jun 2023 15:16:41 -0300 Subject: [PATCH 1/2] Getting numeric value from ureg --- lib/matplotlib/axes/_axes.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 5369eadbdefd..7a31b60a54d2 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -5718,6 +5718,18 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None, `~matplotlib.pyplot.imshow` expects RGB images adopting the straight (unassociated) alpha representation. """ + if not isinstance(vmax, (int, float)): + try: + vmax = vmax.to_tuple()[0] + except ValueError: + raise ValueError("vmax must be a scalar or a 1-element array") + + if not isinstance(vmin, (int, float)): + try: + vmin = vmin.to_tuple()[0] + except ValueError: + raise ValueError("vmin must be a scalar or a 1-element array") + if aspect is None: aspect = mpl.rcParams['image.aspect'] self.set_aspect(aspect) From fe350043502b5735c828ec25d796058c0068eed0 Mon Sep 17 00:00:00 2001 From: lvr44 Date: Sat, 10 Jun 2023 15:27:32 -0300 Subject: [PATCH 2/2] Change exception type --- lib/matplotlib/axes/_axes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 7a31b60a54d2..7e00a1edb73b 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -5721,14 +5721,14 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None, if not isinstance(vmax, (int, float)): try: vmax = vmax.to_tuple()[0] - except ValueError: - raise ValueError("vmax must be a scalar or a 1-element array") + except AttributeError: + raise AttributeError("vmax must be a scalar or a 1-element array") if not isinstance(vmin, (int, float)): try: vmin = vmin.to_tuple()[0] - except ValueError: - raise ValueError("vmin must be a scalar or a 1-element array") + except AttributeError: + raise AttributeError("vmin must be a scalar or a 1-element array") if aspect is None: aspect = mpl.rcParams['image.aspect'] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy