[Python-modules-team] Bug#569008: python-scipy: scipy.stats.kde.gaussian_kde fails with non-obvious exception

Tuure Laurinolli tuure.laurinolli at indagon.com
Tue Feb 9 12:43:20 UTC 2010


Package: python-scipy
Version: 0.7.0-2+b1
Severity: normal


When single-element input is given to scipy.stats.kde.gaussian_kde, it
raises ValueError about infs or NaNs even if the input doesn't contain
any. If computing KDE from single-element input does not make sense, the
exception should report this.

Expected result (with two-element input):

% python -c 'from scipy.stats.kde import gaussian_kde; gaussian_kde([1,2])'
/usr/lib/python2.5/site-packages/scipy/stats/stats.py:1486: DeprecationWarning: scipy.stats.cov is deprecated; please update your code to use numpy.cov.
Please note that:
    - numpy.cov rowvar argument defaults to true, not false
    - numpy.cov bias argument defaults to false, not true

  """, DeprecationWarning)
/usr/lib/python2.5/site-packages/scipy/stats/stats.py:420: DeprecationWarning: scipy.stats.mean is deprecated; please update your code to use numpy.mean.
Please note that:
    - numpy.mean axis argument defaults to None, not 0
    - numpy.mean has a ddof argument to replace bias in a more general manner.
      scipy.stats.mean(a, bias=True) can be replaced by numpy.mean(x,
axis=0, ddof=1).
  axis=0, ddof=1).""", DeprecationWarning)

Actual result:

% python -c 'from scipy.stats.kde import gaussian_kde; gaussian_kde([1])'
/usr/lib/python2.5/site-packages/scipy/stats/stats.py:1486: DeprecationWarning: scipy.stats.cov is deprecated; please update your code to use numpy.cov.
Please note that:
    - numpy.cov rowvar argument defaults to true, not false
    - numpy.cov bias argument defaults to false, not true

  """, DeprecationWarning)
/usr/lib/python2.5/site-packages/scipy/stats/stats.py:420: DeprecationWarning: scipy.stats.mean is deprecated; please update your code to use numpy.mean.
Please note that:
    - numpy.mean axis argument defaults to None, not 0
    - numpy.mean has a ddof argument to replace bias in a more general manner.
      scipy.stats.mean(a, bias=True) can be replaced by numpy.mean(x,
axis=0, ddof=1).
  axis=0, ddof=1).""", DeprecationWarning)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/scipy/stats/kde.py", line 81, in __init__
    self._compute_covariance()
  File "/usr/lib/python2.5/site-packages/scipy/stats/kde.py", line 334, in _compute_covariance
    self.inv_cov = linalg.inv(self.covariance)
  File "/usr/lib/python2.5/site-packages/scipy/linalg/basic.py", line 342, in inv
    a1 = asarray_chkfinite(a)
  File "/usr/lib/python2.5/site-packages/numpy/lib/function_base.py", line 705, in asarray_chkfinite
    raise ValueError, "array must not contain infs or NaNs"
ValueError: array must not contain infs or NaNs

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (700, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.30-2-686 (SMP w/1 CPU core)
Locale: LANG=fi_FI, LC_CTYPE=fi_FI (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/bash

Versions of packages python-scipy depends on:
ii  libamd2.2.0                  1:3.4.0-1   approximate minimum degree orderin
ii  libblas3gf [libblas.so.3gf]  1.2-2       Basic Linear Algebra Subroutines 3
ii  libc6                        2.10.2-2    GNU C Library: Shared libraries
ii  libgcc1                      1:4.4.2-3   GCC support library
ii  libgfortran3                 4.4.2-3     Runtime library for GNU Fortran ap
ii  liblapack3gf [liblapack.so.3 3.2.1-2     library of linear algebra routines
ii  libstdc++6                   4.4.2-3     The GNU Standard C++ Library v3
ii  libumfpack5.4.0              1:3.4.0-1   sparse LU factorization library
ii  python                       2.5.4-5     An interactive high-level object-o
ii  python-central               0.6.14+nmu2 register and build utility for Pyt
ii  python-numpy                 1:1.3.0-3   Numerical Python adds a fast array

Versions of packages python-scipy recommends:
ii  g++ [c++-compiler]            4:4.3.4-1  The GNU C++ compiler
ii  g++-4.3 [c++-compiler]        4.3.4-6    The GNU C++ compiler

Versions of packages python-scipy suggests:
ii  python-profiler               2.5.2-1    deterministic profiling of any Pyt

-- no debconf information





More information about the Python-modules-team mailing list