FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use `repr` in error message Addresses #21959 by jefromyers · Pull Request #24403 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4416,7 +4416,7 @@ def invalid_shape_exception(csize, xsize):
# severe failure => one may appreciate a verbose feedback.
raise ValueError(
f"'c' argument must be a color, a sequence of colors, "
f"or a sequence of numbers, not {c}") from err
f"or a sequence of numbers, not {c!r}") from err
else:
if len(colors) not in (0, 1, xsize):
# NB: remember that a single color is also acceptable.
Expand Down
14 changes: 14 additions & 0 deletions lib/matplotlib/tests/test_axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8290,3 +8290,17 @@ def test_extent_units():
with pytest.raises(ValueError,
match="set_extent did not consume all of the kwargs"):
im.set_extent([2, 12, date_first, date_last], clip=False)


def test_scatter_color_repr_error():

def get_next_color():
return 'blue' # pragma: no cover
msg = (
r"'c' argument must be a color, a sequence of colors"
r", or a sequence of numbers, not 'red\\n'"
)
with pytest.raises(ValueError, match=msg):
c = 'red\n'
mpl.axes.Axes._parse_scatter_color_args(
c, None, kwargs={}, xsize=2, get_next_color_func=get_next_color)

Back | FazBrowse Home | New Git URL