From f490d5e79b0ce2e2b90c6f1c553084e2f58ad218 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Wed, 18 Jan 2023 17:42:28 -0500 Subject: [PATCH 01/22] Update colors.py --- lib/matplotlib/colors.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 575edf6e56c7..9326a86c3545 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -241,7 +241,15 @@ def _check_color_like(**kwargs): for k, v in kwargs.items(): if not is_color_like(v): raise ValueError(f"{v!r} is not a valid value for {k}") - + +def check_color_like_list(**kwargs): + """ + For each *key, lst* pair in *kwargs*, check that every element *v* in *lst* is color-like. + """ + for k, lst in kwargs.items(): + invalid_colors = list(filter(lambda v: not is_color_like(v), lst)) + if invalid_colors: + raise ValueError(f"{invalid_colors} are not valid value(s) for {k}") def same_color(c1, c2): """ From 18972c10bb76088fb97f779b1f7eb143d185f5f1 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Thu, 19 Jan 2023 00:00:24 -0500 Subject: [PATCH 02/22] Update colors.py --- lib/matplotlib/colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 9326a86c3545..befbd7771516 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -247,7 +247,7 @@ def check_color_like_list(**kwargs): For each *key, lst* pair in *kwargs*, check that every element *v* in *lst* is color-like. """ for k, lst in kwargs.items(): - invalid_colors = list(filter(lambda v: not is_color_like(v), lst)) + invalid_colors = list(itertools.filterfalse(lambda v: is_color_like(v), lst)) if invalid_colors: raise ValueError(f"{invalid_colors} are not valid value(s) for {k}") From 5950e5042c9c059611b596dded2d2ee654942dc6 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Thu, 19 Jan 2023 00:21:29 -0500 Subject: [PATCH 03/22] Update colors.py --- lib/matplotlib/colors.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index befbd7771516..e3a328b638ad 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -241,15 +241,18 @@ def _check_color_like(**kwargs): for k, v in kwargs.items(): if not is_color_like(v): raise ValueError(f"{v!r} is not a valid value for {k}") - + + def check_color_like_list(**kwargs): - """ - For each *key, lst* pair in *kwargs*, check that every element *v* in *lst* is color-like. - """ + """ + For each *key, lst* pair in *kwargs*, check that every + element *v* in *lst* is color-like. + """ for k, lst in kwargs.items(): - invalid_colors = list(itertools.filterfalse(lambda v: is_color_like(v), lst)) - if invalid_colors: - raise ValueError(f"{invalid_colors} are not valid value(s) for {k}") + invalid_col = list((lambda v: not is_color_like(v), lst)) + if invalid_col: + raise ValueError(f"{invalid_col} are not valid value(s) for {k}") + def same_color(c1, c2): """ From 9badee82fdda769fa143705b611f97a4638fd0d9 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Thu, 19 Jan 2023 16:52:35 -0500 Subject: [PATCH 04/22] Update lib/matplotlib/colors.py Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> --- lib/matplotlib/colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index e3a328b638ad..fd74830446b8 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -249,7 +249,7 @@ def check_color_like_list(**kwargs): element *v* in *lst* is color-like. """ for k, lst in kwargs.items(): - invalid_col = list((lambda v: not is_color_like(v), lst)) + invalid_col = [c for c in lst if not is color_like(c)] if invalid_col: raise ValueError(f"{invalid_col} are not valid value(s) for {k}") From 477da9f0553f71286f0d27bf59d22f5b7956b2e5 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Fri, 20 Jan 2023 17:06:06 -0500 Subject: [PATCH 05/22] fixes syntax --- lib/matplotlib/colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index fd74830446b8..f6a1e7f01f59 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -249,7 +249,7 @@ def check_color_like_list(**kwargs): element *v* in *lst* is color-like. """ for k, lst in kwargs.items(): - invalid_col = [c for c in lst if not is color_like(c)] + invalid_col = [c for c in lst if not is_color_like(c)] if invalid_col: raise ValueError(f"{invalid_col} are not valid value(s) for {k}") From 456798a8d04abb0226e26d1a760c9ef88992a2d2 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Fri, 20 Jan 2023 17:10:17 -0500 Subject: [PATCH 06/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index a5809f0fa89f..b7ebe665b7de 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1592,3 +1592,18 @@ def test_cm_set_cmap_error(): bad_cmap = 'AardvarksAreAwkward' with pytest.raises(ValueError, match=bad_cmap): sm.set_cmap(bad_cmap) + + +def test_check_color_like(): + assert mcolors._check_color_like(colors1='yellow',colors2='green') is None + with pytest.raises(ValueError, match='none is not a valid value for c'): + mcolors.check_color_like_lst(c='none') + + +def test_check_color_like_list(): + assert mcolors.check_color_like_list(colors=['yellow','orange']) is None + assert mcolors.check_color_like_list(c1=['red','blue'],c2=['green']) is None + with pytest.raises(ValueError, match='none is not a valid value for c'): + mcolors.check_color_like_lst(c=['none','red']) + with pytest.raises(ValueError, match='none is not a valid value for c2'): + mcolors.check_color_like_lst(c1=['red', 'blue'],c2=['abcd']) From 263d51d9f4ebccfcd3f8b5ea73ed39b400114d2f Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Fri, 20 Jan 2023 17:22:55 -0500 Subject: [PATCH 07/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index a5809f0fa89f..9a907ddc453d 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1592,3 +1592,18 @@ def test_cm_set_cmap_error(): bad_cmap = 'AardvarksAreAwkward' with pytest.raises(ValueError, match=bad_cmap): sm.set_cmap(bad_cmap) + + +def test_check_color_like(): + assert mcolors._check_color_like(colors1='yellow', colors2='red') is None + with pytest.raises(ValueError, match='none is not a valid value for c'): + mcolors.check_color_like_lst(c='none') + + +def test_check_color_like_list(): + assert mcolors.check_color_like_list(colors=['yellow', 'orange']) is None + assert mcolors.check_color_like_list(c1=['red'], c2=['blue']) is None + with pytest.raises(ValueError, match='none is not a valid value for c'): + mcolors.check_color_like_lst(c=['none', 'red']) + with pytest.raises(ValueError, match='none is not a valid value for c2'): + mcolors.check_color_like_lst(c1=['red', 'blue'], c2=['abcd']) From 60c0ffa341bb8ce54e9d5136b90cb357696d47aa Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Fri, 20 Jan 2023 17:48:29 -0500 Subject: [PATCH 08/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 9a907ddc453d..e945bf533e26 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1597,13 +1597,13 @@ def test_cm_set_cmap_error(): def test_check_color_like(): assert mcolors._check_color_like(colors1='yellow', colors2='red') is None with pytest.raises(ValueError, match='none is not a valid value for c'): - mcolors.check_color_like_lst(c='none') + mcolors.check_color_like(c='none') def test_check_color_like_list(): assert mcolors.check_color_like_list(colors=['yellow', 'orange']) is None assert mcolors.check_color_like_list(c1=['red'], c2=['blue']) is None with pytest.raises(ValueError, match='none is not a valid value for c'): - mcolors.check_color_like_lst(c=['none', 'red']) + mcolors.check_color_like_list(c=['none', 'red']) with pytest.raises(ValueError, match='none is not a valid value for c2'): - mcolors.check_color_like_lst(c1=['red', 'blue'], c2=['abcd']) + mcolors.check_color_like_list(c1=['red', 'blue'], c2=['abcd']) From 5ee5b268a58244e58c24d5ba439b55e586dcbbb2 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Fri, 20 Jan 2023 18:09:03 -0500 Subject: [PATCH 09/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index e945bf533e26..28bd22b4b8c2 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1597,7 +1597,7 @@ def test_cm_set_cmap_error(): def test_check_color_like(): assert mcolors._check_color_like(colors1='yellow', colors2='red') is None with pytest.raises(ValueError, match='none is not a valid value for c'): - mcolors.check_color_like(c='none') + mcolors._check_color_like(c='none') def test_check_color_like_list(): From 49d86c6b8c2ea103e442a4bfeece8d4f4e662da4 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Fri, 20 Jan 2023 18:38:22 -0500 Subject: [PATCH 10/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 28bd22b4b8c2..3eca230ad75f 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1595,15 +1595,17 @@ def test_cm_set_cmap_error(): def test_check_color_like(): + err_msg = '[\'none\'] is not a valid value for c' assert mcolors._check_color_like(colors1='yellow', colors2='red') is None - with pytest.raises(ValueError, match='none is not a valid value for c'): + with pytest.raises(ValueError, match=err_msg): mcolors._check_color_like(c='none') def test_check_color_like_list(): + err_msg = '[\'none\'] is not a valid value for c' assert mcolors.check_color_like_list(colors=['yellow', 'orange']) is None assert mcolors.check_color_like_list(c1=['red'], c2=['blue']) is None - with pytest.raises(ValueError, match='none is not a valid value for c'): + with pytest.raises(ValueError, match=err_msg): mcolors.check_color_like_list(c=['none', 'red']) - with pytest.raises(ValueError, match='none is not a valid value for c2'): - mcolors.check_color_like_list(c1=['red', 'blue'], c2=['abcd']) + with pytest.raises(ValueError, match=err_msg): + mcolors.check_color_like_list(c1=['red', 'blue'], c=['abcd']) From b986c7c8e9ca053d5341669c61ebb0a4b8ada82e Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Fri, 20 Jan 2023 18:51:57 -0500 Subject: [PATCH 11/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 3eca230ad75f..120f15f90477 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1608,4 +1608,4 @@ def test_check_color_like_list(): with pytest.raises(ValueError, match=err_msg): mcolors.check_color_like_list(c=['none', 'red']) with pytest.raises(ValueError, match=err_msg): - mcolors.check_color_like_list(c1=['red', 'blue'], c=['abcd']) + mcolors.check_color_like_list(c1=['red', 'blue'], c=['none']) From 7f38555dc3be379f873f6afe1c4a05799b3fb447 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Sat, 21 Jan 2023 20:20:46 -0500 Subject: [PATCH 12/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 120f15f90477..0ac71663d692 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1595,17 +1595,17 @@ def test_cm_set_cmap_error(): def test_check_color_like(): - err_msg = '[\'none\'] is not a valid value for c' + err_msg = '[\'abcd\'] is not a valid value for c' assert mcolors._check_color_like(colors1='yellow', colors2='red') is None with pytest.raises(ValueError, match=err_msg): - mcolors._check_color_like(c='none') + mcolors._check_color_like(c='abcd') def test_check_color_like_list(): - err_msg = '[\'none\'] is not a valid value for c' + err_msg = '[\'abcd\'] is not a valid value for c' assert mcolors.check_color_like_list(colors=['yellow', 'orange']) is None assert mcolors.check_color_like_list(c1=['red'], c2=['blue']) is None with pytest.raises(ValueError, match=err_msg): - mcolors.check_color_like_list(c=['none', 'red']) + mcolors.check_color_like_list(c=['abcd', 'red']) with pytest.raises(ValueError, match=err_msg): - mcolors.check_color_like_list(c1=['red', 'blue'], c=['none']) + mcolors.check_color_like_list(c1=['red', 'blue'], c=['abcd']) From 3b4974654ba1be046246f6df2463120f5ce152f9 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Sun, 22 Jan 2023 16:02:28 -0500 Subject: [PATCH 13/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 0ac71663d692..dee6a9d08532 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1602,7 +1602,7 @@ def test_check_color_like(): def test_check_color_like_list(): - err_msg = '[\'abcd\'] is not a valid value for c' + err_msg = '[\'abcd\'] are not valid value(s) for c' assert mcolors.check_color_like_list(colors=['yellow', 'orange']) is None assert mcolors.check_color_like_list(c1=['red'], c2=['blue']) is None with pytest.raises(ValueError, match=err_msg): From 6abb7a0556fa35fd8050f502074df6a639b8fde0 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Sun, 22 Jan 2023 16:39:28 -0500 Subject: [PATCH 14/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index dee6a9d08532..ed43e19d39ef 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1595,14 +1595,14 @@ def test_cm_set_cmap_error(): def test_check_color_like(): - err_msg = '[\'abcd\'] is not a valid value for c' + err_msg = "['abcd'] is not a valid value for c" assert mcolors._check_color_like(colors1='yellow', colors2='red') is None with pytest.raises(ValueError, match=err_msg): mcolors._check_color_like(c='abcd') def test_check_color_like_list(): - err_msg = '[\'abcd\'] are not valid value(s) for c' + err_msg = "['abcd'] are not valid value(s) for c" assert mcolors.check_color_like_list(colors=['yellow', 'orange']) is None assert mcolors.check_color_like_list(c1=['red'], c2=['blue']) is None with pytest.raises(ValueError, match=err_msg): From 3176b645b8809dc23e43b4910faeb1af20da4eae Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Sun, 22 Jan 2023 19:50:02 -0500 Subject: [PATCH 15/22] Update colors.py --- lib/matplotlib/colors.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index f6a1e7f01f59..229f744801eb 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -251,7 +251,8 @@ def check_color_like_list(**kwargs): for k, lst in kwargs.items(): invalid_col = [c for c in lst if not is_color_like(c)] if invalid_col: - raise ValueError(f"{invalid_col} are not valid value(s) for {k}") + raise ValueError( + f"{invalid_col!r} are not valid value(s) for {k}") def same_color(c1, c2): From b79f09f67f0c555ac718038a6670ba76d7e2d525 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Sun, 22 Jan 2023 20:28:57 -0500 Subject: [PATCH 16/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index ed43e19d39ef..4ad2c4fa2b3a 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1602,7 +1602,7 @@ def test_check_color_like(): def test_check_color_like_list(): - err_msg = "['abcd'] are not valid value(s) for c" + err_msg = r"['abcd'] are not valid value(s) for c" assert mcolors.check_color_like_list(colors=['yellow', 'orange']) is None assert mcolors.check_color_like_list(c1=['red'], c2=['blue']) is None with pytest.raises(ValueError, match=err_msg): From 7beccba8ea46533e3a50df3b2985179c8effed22 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Sun, 22 Jan 2023 20:57:35 -0500 Subject: [PATCH 17/22] Update colors.py --- lib/matplotlib/colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 229f744801eb..50fa8d9d21ad 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -252,7 +252,7 @@ def check_color_like_list(**kwargs): invalid_col = [c for c in lst if not is_color_like(c)] if invalid_col: raise ValueError( - f"{invalid_col!r} are not valid value(s) for {k}") + re.escape(f"{invalid_col!r} are not valid value(s) for {k}")) def same_color(c1, c2): From 42e13ba243360602a0bf5e50afa4e63d627531a7 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Sun, 22 Jan 2023 21:20:40 -0500 Subject: [PATCH 18/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 4ad2c4fa2b3a..ed43e19d39ef 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1602,7 +1602,7 @@ def test_check_color_like(): def test_check_color_like_list(): - err_msg = r"['abcd'] are not valid value(s) for c" + err_msg = "['abcd'] are not valid value(s) for c" assert mcolors.check_color_like_list(colors=['yellow', 'orange']) is None assert mcolors.check_color_like_list(c1=['red'], c2=['blue']) is None with pytest.raises(ValueError, match=err_msg): From 114a2fd57188f84321e35d79d5ba849e1de92d80 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Mon, 23 Jan 2023 00:17:57 -0500 Subject: [PATCH 19/22] :( --- lib/matplotlib/colors.py | 4 ++-- lib/matplotlib/tests/test_colors.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 50fa8d9d21ad..8bd92b2a460f 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -251,8 +251,8 @@ def check_color_like_list(**kwargs): for k, lst in kwargs.items(): invalid_col = [c for c in lst if not is_color_like(c)] if invalid_col: - raise ValueError( - re.escape(f"{invalid_col!r} are not valid value(s) for {k}")) + err_msg = f"{invalid_col!r} are not valid values for {k}" + raise ValueError(re.escape(err_msg)) def same_color(c1, c2): diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index ed43e19d39ef..a61816ab57dd 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -18,6 +18,7 @@ import matplotlib.pyplot as plt import matplotlib.scale as mscale from matplotlib.testing.decorators import image_comparison, check_figures_equal +from re import escape @pytest.mark.parametrize('N, result', [ @@ -1602,7 +1603,7 @@ def test_check_color_like(): def test_check_color_like_list(): - err_msg = "['abcd'] are not valid value(s) for c" + err_msg = escape("['abcd'] are not valid values for c") assert mcolors.check_color_like_list(colors=['yellow', 'orange']) is None assert mcolors.check_color_like_list(c1=['red'], c2=['blue']) is None with pytest.raises(ValueError, match=err_msg): From 5c68d13d17790c50638cf39c25bf1f42e7be4d73 Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Tue, 24 Jan 2023 17:40:40 -0500 Subject: [PATCH 20/22] Update lib/matplotlib/colors.py Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com> --- lib/matplotlib/colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 8bd92b2a460f..4f38eec71e1d 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -252,7 +252,7 @@ def check_color_like_list(**kwargs): invalid_col = [c for c in lst if not is_color_like(c)] if invalid_col: err_msg = f"{invalid_col!r} are not valid values for {k}" - raise ValueError(re.escape(err_msg)) + raise ValueError(err_msg) def same_color(c1, c2): From 14e7ea9824a3581ec2681d23c611f8bc52e3374d Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Tue, 24 Jan 2023 17:46:46 -0500 Subject: [PATCH 21/22] Update test_colors.py --- lib/matplotlib/tests/test_colors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index a61816ab57dd..31421e51861e 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1,6 +1,7 @@ import copy import itertools import unittest.mock +from re import escape from io import BytesIO import numpy as np @@ -18,7 +19,6 @@ import matplotlib.pyplot as plt import matplotlib.scale as mscale from matplotlib.testing.decorators import image_comparison, check_figures_equal -from re import escape @pytest.mark.parametrize('N, result', [ From 04cb73114930cf7c31dace187ca82d91358d73cc Mon Sep 17 00:00:00 2001 From: i-deal <113572023+i-deal@users.noreply.github.com> Date: Wed, 25 Jan 2023 22:12:10 -0500 Subject: [PATCH 22/22] update syntax --- lib/matplotlib/colors.py | 2 +- lib/matplotlib/tests/test_colors.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 4f38eec71e1d..e859edd05dff 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -243,7 +243,7 @@ def _check_color_like(**kwargs): raise ValueError(f"{v!r} is not a valid value for {k}") -def check_color_like_list(**kwargs): +def _check_color_like_list(**kwargs): """ For each *key, lst* pair in *kwargs*, check that every element *v* in *lst* is color-like. diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index 31421e51861e..6680581d49fb 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -1604,9 +1604,9 @@ def test_check_color_like(): def test_check_color_like_list(): err_msg = escape("['abcd'] are not valid values for c") - assert mcolors.check_color_like_list(colors=['yellow', 'orange']) is None - assert mcolors.check_color_like_list(c1=['red'], c2=['blue']) is None + assert mcolors._check_color_like_list(colors=['yellow', 'orange']) is None + assert mcolors._check_color_like_list(c1=['red'], c2=['blue']) is None with pytest.raises(ValueError, match=err_msg): - mcolors.check_color_like_list(c=['abcd', 'red']) + mcolors._check_color_like_list(c=['abcd', 'red']) with pytest.raises(ValueError, match=err_msg): - mcolors.check_color_like_list(c1=['red', 'blue'], c=['abcd']) + mcolors._check_color_like_list(c1=['red', 'blue'], c=['abcd'])