Value checking the numpoints argument to be a whole number.#6949
Closed
pfaion wants to merge 1 commit intomatplotlib:masterfrom
pfaion:numpoints-value-check
Closed
Value checking the numpoints argument to be a whole number.#6949pfaion wants to merge 1 commit intomatplotlib:masterfrom pfaion:numpoints-value-check
pfaion wants to merge 1 commit intomatplotlib:masterfrom
pfaion:numpoints-value-check
Conversation
| ncol = 1 | ||
| self._ncol = ncol | ||
|
|
||
| if ( |
Member
There was a problem hiding this comment.
It is probably better to do something like if int(n) != n: raise.
Should probably make numpoints a property and do the validation on the way in as well.
This should probably also check that numpoints > 0.
Member
There was a problem hiding this comment.
The check for numpoints > 0 is just below
Member
|
I think we can close this now |
Member
|
Keeping some sort of validation, but via duck-typing, is still a good idea. Or just casting it to an int. |
tacaswell
requested changes
Apr 18, 2017
Member
tacaswell
left a comment
There was a problem hiding this comment.
Do not use explicit type checking here.
Contributor
|
I vote to let legend_handler take care of the validation, i.e. #8478 is enough IMO. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Referencing issue #6921, if you accidentally provide a decimal fraction as numpoints, you get a strange error in another file (https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/legend_handler.py#L151) not reflecting the real problem. This can be fixed by checking for whole numbers.
I included checking for whole floats as well, in case the value gets calculated through some floating point formula. If that doesn't make any sense, I can remove it again.