Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6310073

Browse filesBrowse files
authored
Merge pull request #22665 from oscargus/emptycolorerrormessage
ENH: Improve error message for incorrect color string
2 parents c47f770 + 52642c7 commit 6310073
Copy full SHA for 6310073

File tree

Expand file treeCollapse file tree

2 files changed

+2
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+2
-5
lines changed

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,7 @@ def to_rgba_array(c, alpha=None):
362362
pass
363363

364364
if isinstance(c, str):
365-
raise ValueError("Using a string of single character colors as "
366-
"a color sequence is not supported. The colors can "
367-
"be passed as an explicit list instead.")
365+
raise ValueError(f"{c!r} is not a valid color value.")
368366

369367
if len(c) == 0:
370368
return np.zeros((0, 4), float)

‎lib/matplotlib/tests/test_colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colors.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,7 @@ def test_to_rgba_array_single_str():
12531253

12541254
# single char color sequence is invalid
12551255
with pytest.raises(ValueError,
1256-
match="Using a string of single character colors as "
1257-
"a color sequence is not supported."):
1256+
match="'rgb' is not a valid color value."):
12581257
array = mcolors.to_rgba_array("rgb")
12591258

12601259

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.