Problem
I mistakenly supplied "blue\n" as the argument c for matplotlib.axes.Axes.scatter , then matplitlib claimed for illegal color name like this:
ValueError: 'c' argument must be a color, a sequence of colors, or a sequence of numbers, not blue
I was not aware that the argument actually contained a trailing newline so I was very confused.
Proposed solution
The error message would be nicer if it outputs user's input via repr.
For example, in this case the error message here can be easily replced with:
raise ValueError(
f"'c' argument must be a color, a sequence of colors, "
f"or a sequence of numbers, not {c!r}") from
so that we may now get an easy-to-troubleshoot error like this:
ValueError: 'c' argument must be a color, a sequence of colors, or a sequence of numbers, not "blue\n"
This kind of improvement can be applied to many other places.
Problem
I mistakenly supplied
"blue\n"as the argumentcformatplotlib.axes.Axes.scatter, thenmatplitlibclaimed for illegal color name like this:I was not aware that the argument actually contained a trailing newline so I was very confused.
Proposed solution
The error message would be nicer if it outputs user's input via
repr.For example, in this case the error message here can be easily replced with:
so that we may now get an easy-to-troubleshoot error like this:
This kind of improvement can be applied to many other places.