[Numpy-discussion] Re: [SciPy-dev] unique hanging?

Sasha ndarray at mac.com
Tue Mar 14 17:40:01 CST 2006


This really belongs to numpy-discussion.

What you observe is probably the consequence of nan not being equal to itself:

>>> N.equal(N.nan,N.nan)
False

Many algorithms would fail to terminate or produce wrong results when
they encounter such an anomaly.

For example:

>>> N.sort([N.nan,5, N.nan, 3])
array([        nan,  5.        ,         nan,  3.        ])

This is unfortunate, but not really a bug.  I would suggest that we
document which numpy functions are nan safe and which are not.



On 3/14/06, Jonathan Taylor <jonathan.taylor at stanford.edu> wrote:
> hi all,
>
> apologize if this is not the right list -- in the latest svn of numpy
> unique seems to be taking a long time with "nan"
>
> reproducible error:
>
> -------------------------------------------------------------------------------------------
> import numpy as N
> import numpy.random as R
>
> x = R.standard_normal((100000,))
> x = N.around(x * 100.) / 100.
>
> print len(N.unique(x))
>
> x[0] = N.nan
> print len(N.unique(x))
>
>
> x[0:50000] = N.nan
> print 'OK'
>
> print len(N.unique(x))
>
>
> --
> ------------------------------------------------------------------------
> I'm part of the Team in Training: please support our efforts for the
> Leukemia and Lymphoma Society!
>
> http://www.active.com/donate/tntsvmb/tntsvmbJTaylor
>
> GO TEAM !!!
>
> ------------------------------------------------------------------------
> Jonathan Taylor                           Tel:   650.723.9230
> Dept. of Statistics                       Fax:   650.725.8977
> Sequoia Hall, 137                         www-stat.stanford.edu/~jtaylo
> 390 Serra Mall
> Stanford, CA 94305
>
>
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-dev
>
>
>
>




More information about the Numpy-discussion mailing list