[SciPy-dev] scipy.stats._chk_asarray

ctw lists.20.chth@xoxy....
Tue Jun 2 15:56:57 CDT 2009


I just wanted to give you a heads up that I came across a bug in
scipy.stats._chk_asarray.
I have updated the corresponding review page (
http://projects.scipy.org/scipy/ticket/44 ) with the following
comment:

_chk_asarray does not respect the class of the input. If the input is
a subclass of numpy.ndarray _chk_asarray will transform it into an
ndarray. This can lead to undesirable consequences in functions that
call _chk_asarray (e.g., scipy.stats.nanmean).

Simple example:
>>> tst = matrix(range(4))
>>> scipy.stats.nanmean(tst)
 array([0., 1., 2., 3.])
>>> np.mean(tst,0)
 matrix([[0., 1., 2., 3.]])

The problem is the call to np.asarray() which should only be made for
input that is not an ndarray instance. I just committed a
corresponding fix via SVN.


More information about the Scipy-dev mailing list