You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Raise error if argument to xlim is invalid, e.g., nan #7460
As of 2.0b4, passing nan as a limit to xlim seems to reset both limits to (-0.001, 0.001) (try e.g. with plt.plot([0, 1]); plt.xlim(right=np.nan)). I think this should either error, or, more usefully, be interpreted as None (i.e. leave that limit as is). (For extra points, we can also bikeshed what passing inf to xlim should mean.)
The main use case would be when the xlim is read from some float context (e.g. from an array) where you can easily store nan but not None.
changed the title [-]let `xlim(left=np.nan, right=...)` be synonymous to `xlim(left=None, right=...)`[/-][+]Raise error if argument to xlim is invalid, e.g., nan[/+]on Nov 27, 2016
Activity
tacaswell commentedon Nov 15, 2016
Biased toward erroring, using
np.nanas a stand in forNoneseems a bit too clever and surprising, but am open to be talked into it.From git-blame, I think that this behavior has been long standing (e356a15 in 2008 from @efiring )
NelleV commentedon Nov 15, 2016
So your suggestion is to raise an error?
NelleV commentedon Nov 15, 2016
(I'd raise an error…)
tacaswell commentedon Nov 20, 2016
That seems to be 1.5 votes to error.
efiring commentedon Nov 20, 2016
Make that 2.5.
anntzer commentedon Nov 20, 2016
I'm fine with making it an error too. Same with
inf?efiring commentedon Nov 20, 2016
Yes. Sounds like an
np.isfinitecheck is in order.[-]let `xlim(left=np.nan, right=...)` be synonymous to `xlim(left=None, right=...)`[/-][+]Raise error if argument to xlim is invalid, e.g., nan[/+]bcongdon commentedon Jan 4, 2017
Working on this now. It looks like
np.isfiniteraises an error if you pass it something non-numeric, like a date.Do we need the full
np.isfinitecheck, or can we just rejectnp.nanandnp.infvalues?efiring commentedon Jan 4, 2017
I think you can handle that by putting the check after the calls to
convert_xunits; I think thatnp.isfiniteshould be safe there.tacaswell commentedon Mar 7, 2017
We now have 3 PRs for this!
Merge pull request #8022 from nvedant07/first_try
QuLogic commentedon Apr 13, 2017
Closed by #7744 and #8022.