Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Added axis limit check for non-finite values #7744
Conversation
|
Should this raise a warning instead of an error? Currently invalid limits on a log axis raises a warning (#7367), which I think is best. Either way either a warning or error should be raised consistently. |
|
Yeah, that sounds like the better approach. Passing an invalid value to |
codecov-io
commented
Jan 5, 2017
•
Current coverage is 62.12% (diff: 100%)@@ master #7744 diff @@
==========================================
Files 174 174
Lines 56028 56032 +4
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 34805 34808 +3
- Misses 21223 21224 +1
Partials 0 0
|
tacaswell
added this to the
2.1 (next point release)
milestone
Jan 7, 2017
|
The consensus in #7460 seemed to be in favor of errors, not warnings. It seems that warnings either just annoy people (because they are doing the thing for a good reason) or are ignored. I think this will still re-set the limits, which was the original complaint. |
anntzer
referenced
this pull request
Jan 13, 2017
Open
Trying to set_ylim(bottom=0) on a log scaled axis changes plot #7733
|
Please note #7733 (comment). |
|
I've looked over the discussion on #7733 and related issues. Still a bit confused on how to proceed. I think the issues are somewhat unrelated in that the solution for #7735 - letting invalid values pass through - is actually the cause of the issue this PR addresses (#7460). I've reset back to the commit that raises errors instead of warnings. |
|
Rebased. |
| @@ -4931,3 +4931,15 @@ def test_bar_single_height(): | ||
| ax.bar(range(4), 1) | ||
| # Check that a horizontal chart with one width works | ||
| ax.bar(0, 1, bottom=range(4), width=1, orientation='horizontal') | ||
| + | ||
| + | ||
| +def test_invalid_axis_limits(): |
dstansby
Feb 5, 2017
Contributor
One last thing, could a @cleanup decorator go above this line. Otherwise looks good!
| + if ((left is not None and not np.isfinite(left)) or | ||
| + (right is not None and not np.isfinite(right))): | ||
| + raise ValueError("xlim limits must be finite. " | ||
| + "instead, found: (%s, %s)" % (left, right)) |
QuLogic
Feb 5, 2017
Member
'xlim limits' is a bit redundant. Also, 'instead' comes after a period so should be capitalized. Something like 'Specified x limits must be finite; instead found: (%s, %s)'.
bcongdon
Feb 6, 2017
Contributor
Alright, sounds good. That redundancy bothered me too, but I couldn't think of the right verbiage to describe the warning. Thanks!
| + if ((top is not None and not np.isfinite(top)) or | ||
| + (bottom is not None and not np.isfinite(bottom))): | ||
| + raise ValueError("ylim limits must be finite. " | ||
| + "instead, found: (%s, %s)" % (top, bottom)) |
| @@ -3176,7 +3176,7 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw): | ||
| if ((top is not None and not np.isfinite(top)) or | ||
| (bottom is not None and not np.isfinite(bottom))): | ||
| - raise ValueError("ylim limits must be finite. " | ||
| + raise ValueError("Specified y limits must be finite; " | ||
| "instead, found: (%s, %s)" % (top, bottom)) |
QuLogic
dismissed
dstansby’s
review
Feb 6, 2017
Not needed on master.
|
@tacaswell To what documentation are you referring in your review? Can it be dismissed? |
QuLogic
changed the title from
Added axis limit check for non-finite values to [MRG+1] Added axis limit check for non-finite values
Feb 26, 2017
|
Ping @tacaswell? |
bcongdon commentedJan 5, 2017
Addresses #7460.
Raises a
ValueErrorif non-finite values likenp.nanornp.infare passed as arguments toset_xlimorset_ylim.