[SciPy-dev] Bug in scipy.stats.kde?
Dave Hirschfeld
novin01@gmail....
Fri Oct 12 11:06:57 CDT 2007
Unless I'm mistaken it appears there's a bug in scipy.stats.kde as demonstrated
in the example below.
It appears that line 205 is referencing np (numpy) which has not been imported.
At the top of the file ravel has been imported from numpy so the solution
appears to be to simply remove the reference to np in the integrate_box_1d
function.
Regards,
Dave
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 0.8.1 -- An enhanced Interactive Python.
In [1]: import scipy
In [2]: scipy.__version__
Out[2]: '0.7.0.dev3433'
In [3]: from scipy import randn, stats
In [4]: pdf = stats.kde.gaussian_kde(randn(1000))
In [5]: pdf.integrate_box_1d(-3,3)
---------------------------------------------------------------------------
<type 'exceptions.NameError'> Traceback (most recent call last)
C:\development\sandbox\<ipython console> in <module>()
C:\Python25\Lib\site-packages\scipy\stats\kde.py in integrate_box_1d(self, low,
high)
203 raise ValueError("integrate_box_1d() only handles 1D pdfs")
204
--> 205 stdev = np.ravel(sqrt(self.covariance))[0]
206
207 normalized_low = ravel((low - self.dataset)/stdev)
<type 'exceptions.NameError'>: global name 'np' is not defined
In [6]:
More information about the Scipy-dev
mailing list