[Numpy-discussion] searchsorted bug

Hans Meine meine@informatik.uni-hamburg...
Thu Jan 31 09:45:03 CST 2008


Am Donnerstag, 31. Januar 2008 15:35:25 schrieb James Philbin:
> The following gives the wrong answer:
>
> In [2]: A = array(['a','aa','b'])
>
> In [3]: B = array(['d','e'])
>
> In [4]: A.searchsorted(B)
> Out[4]: array([3, 0])
>
> The answer should be [3,3].
Heh, I got both answers in the same session (not 100% reproducable, but 
several times already)!

In [1]: %cpaste
Pasting code; enter '--' alone on the line to stop.
:>>> import numpy
:>>> A = numpy.array(['a','aa','b'])
:>>> B = numpy.array(['d','e'])
:>>> print A.searchsorted(B)
:>>> print numpy.__version__
:--

[3 3]
1.0.5.dev4420

In [2]:

In [3]: print A.searchsorted(B)
[3 3]

In [4]: print A.searchsorted(B)
[3 3]

In [5]: print A.searchsorted(B)
[3 3]

In [6]: %cpaste
Pasting code; enter '--' alone on the line to stop.
:>>> import numpy
:>>> A = numpy.array(['a','aa','b'])
:>>> B = numpy.array(['d','e'])
:>>> print A.searchsorted(B)
:>>> print numpy.__version__
:--
[3 0]
1.0.5.dev4420

-- 
Ciao, /  /
     /--/
    /  / ANS


More information about the Numpy-discussion mailing list