Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit04ce3e9

Browse files
authored
Userepr in scatter error message (#24403)
* use repr in error messagecloses#21959* add test for repr error message* fix formatting* clean up formatting and naming* add `pragma: no cover`* remove import and function name a bit more explicit
1 parentdf761c9 commit04ce3e9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4416,7 +4416,7 @@ def invalid_shape_exception(csize, xsize):
44164416
# severe failure => one may appreciate a verbose feedback.
44174417
raiseValueError(
44184418
f"'c' argument must be a color, a sequence of colors, "
4419-
f"or a sequence of numbers, not{c}")fromerr
4419+
f"or a sequence of numbers, not{c!r}")fromerr
44204420
else:
44214421
iflen(colors)notin (0,1,xsize):
44224422
# NB: remember that a single color is also acceptable.

‎lib/matplotlib/tests/test_axes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8290,3 +8290,17 @@ def test_extent_units():
82908290
withpytest.raises(ValueError,
82918291
match="set_extent did not consume all of the kwargs"):
82928292
im.set_extent([2,12,date_first,date_last],clip=False)
8293+
8294+
8295+
deftest_scatter_color_repr_error():
8296+
8297+
defget_next_color():
8298+
return'blue'# pragma: no cover
8299+
msg= (
8300+
r"'c' argument must be a color, a sequence of colors"
8301+
r", or a sequence of numbers, not 'red\\n'"
8302+
)
8303+
withpytest.raises(ValueError,match=msg):
8304+
c='red\n'
8305+
mpl.axes.Axes._parse_scatter_color_args(
8306+
c,None,kwargs={},xsize=2,get_next_color_func=get_next_color)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp