Repository navigation
DOC: Better error when float on datetime axis - #10084
Conversation
|
|
||
| if dmin < 1: | ||
| raise ValueError('datalim minimum {} < 1. This often ' | ||
| 'happens if you pass a float to an ' |
| raise ValueError('cannot convert {} < 1 to a date. This ' | ||
| 'often happens if floats are passed to ' | ||
| 'a Matplotlib axis that expects datetime objects. ' | ||
| ''.format(ix)) |
There was a problem hiding this comment.
you don't need the '', starting the line with a dot binds to the string on the previous line
| if ix < 1: | ||
| raise ValueError('cannot convert {} < 1 to a date. This ' | ||
| 'often happens if floats are passed to ' | ||
| 'a Matplotlib axis that expects datetime objects. ' |
There was a problem hiding this comment.
to an axis (no need to mpl, which you also did not include below)
anntzer
left a comment
There was a problem hiding this comment.
minor formatting/wording can be improved but nothing blocking
f02880f to
50969c4
Compare
|
|
||
| if dmin < 1: | ||
| raise ValueError('datalim minimum {} < 1. This often ' | ||
| 'happens if you pass a float to an ' |
There was a problem hiding this comment.
Can "float" be change to something less technical like "number" or "normal number"?
There was a problem hiding this comment.
value that is not a datetime?
|
(apart from my suggested change I am +10000 on this, since I remember in my early Matplotlib days spending ages meaning what on earth the current error message meant) |
|
Yep I’ll fix it this pm. No problem making it even clearer. |
50969c4 to
88a19c2
Compare
|
Done - I couldn't get a test to work, however. 🐑 If I do: g, ax = plt.subplots()
ax.plot(datetime(2017, 1, 1), 1)
ax.plot(1, 1)
fig.draw(fig.canvas.get_renderer())I get the error. Trying to do this in |
|
|
||
| ix = int(x) | ||
| if ix < 1: | ||
| raise ValueError('cannot convert {} < 1 to a date. This ' |
There was a problem hiding this comment.
I think should be:
cannot convert {} to a date
{} < 1 evaluate to a bool 😉
There was a problem hiding this comment.
OK. Changed to
'view limit minimum {} is less than 1 and '
'is an invalid Matplotlib date value. This '
'often happens if you pass a non-datetime '
'value to an axis that has datetime units'
.format(vmin))
88a19c2 to
38b137b
Compare
38b137b to
a4759e8
Compare
PR Summary
#9211 points out that the error message after
yields the mysterious error:
This PR catches earlier and returns:
PR Checklist