From ff79f0128d6e471c7cc2b3d905dd7c8a4f6e92af Mon Sep 17 00:00:00 2001 From: iofall <50991099+iofall@users.noreply.github.com> Date: Sat, 3 Dec 2022 20:30:04 +0530 Subject: [PATCH] Gracefully fail the string validator for tuple inputs Partially closes - #22338 --- lib/matplotlib/rcsetup.py | 2 +- lib/matplotlib/tests/test_rcparams.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 5a5914ba7b3b..9061a1373703 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -68,7 +68,7 @@ def __call__(self, s): name, = (k for k, v in globals().items() if v is self) _api.warn_deprecated( self._deprecated_since, name=name, obj_type="function") - if self.ignorecase: + if self.ignorecase and isinstance(s, str): s = s.lower() if s in self.valid: return self.valid[s] diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index d5f316f54595..7120f6c021de 100644 --- a/lib/matplotlib/tests/test_rcparams.py +++ b/lib/matplotlib/tests/test_rcparams.py @@ -1,6 +1,7 @@ import copy import os from pathlib import Path +import re import subprocess import sys from unittest import mock @@ -591,3 +592,10 @@ def test_deprecation(monkeypatch): # Note that the warning suppression actually arises from the # iteration over the updater rcParams being protected by # suppress_matplotlib_deprecation_warning, rather than any explicit check. + + +def test_rcparams_legend_loc(): + value = (0.9, .7) + match_str = f"{value} is not a valid value for legend.loc;" + with pytest.raises(ValueError, match=re.escape(match_str)): + mpl.RcParams({'legend.loc': value}) 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