[SciPy-Dev] Warnings raised (from fit in scipy.stats)
Skipper Seabold
jsseabold@gmail....
Fri Jun 11 11:45:05 CDT 2010
Since the raising of warning behavior has been changed (I believe), I
have been running into a lot of warnings in my code when say I do
something like
In [120]: from scipy import stats
In [121]: y = [-45, -3, 1, 0, 1, 3]
In [122]: v = stats.norm.pdf(y)/stats.norm.cdf(y)
Warning: invalid value encountered in divide
Sometimes, this is useful to know. Sometimes, though, it's very
disturbing when it's encountered in some kind of iteration or
optimization. I have been using numpy.clip to get around this in my
own code, but when it's buried a bit deeper, it's not quite so simple.
Take this example.
In [123]: import numpy as np
In [124]: np.random.seed(12345)
In [125]: B = 6.0
In [126]: x = np.random.exponential(scale=B, size=5000)
In [127]: from scipy.stats import expon
In [128]: expon.fit(x)
<dozens of warnings clipped>
Out[128]: (0.21874043533906118, 5.7122829778172939)
The fit is achieved by fmin (as far as I know, since disp=0 in the
rv_continuous.fit...), but there are a number of warnings emitted. Is
there any middle ground to be had in these type of situations via
context management perhaps?
Should I file a ticket?
Skipper
More information about the SciPy-Dev
mailing list