Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e30cd8e

Browse files
committed
Improve error message for empty string color
1 parent e3c8195 commit e30cd8e

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

lib/matplotlib/colors.py

Lines 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

Lines 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)