New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lw float cast #4327
Fix lw float cast #4327
Conversation
Explicitly cast linewidth to a float in `set_linewidth` methods of `Line2D` and `Patch` Closes matplotlib#4306
Closes #4306 |
This looks reasonable and will do the job--but I'm still uncomfortable with the idea of supporting |
On the other hand, supporting 'float like' seems very much in the spirit of python and duck typing. This will also clean up any issues with scalar numpy arrays or integers going through. |
A string does not behave like a number, so no, it is not in the spirit of duck typing. A string is not "float-like" at all. It doesn't pass our |
Fair enough, I was using 'float-like' <-> I had forgotten that detail in the colorspec. The alternative I see is if is_numlike(lw):
lw = float(lw) # still want to homogenize for down stream I think
else:
raise ValueError("...") My inclination is to be as permissive as possible, but will change them all over to this form if you want. |
This brings us to some strategy questions regarding input argument validation that should be addressed but can be deferred. For the time being I don't mind leaving the PR as-is; but I don't want it to be seen as endorsing or even officially supporting string inputs where numbers are called for. |
Fully on board with not endorsing string input for linewidth and would have no problem breaking this API with out warning (so long as we push the exception way up the interaction stack). |
there is a
set_linewidth
inbackend_gdk.py
, but it calls the parent classset_linewdith
which already has the needed cast.