From: Charles R H. <cha...@gm...> - 2006-10-30 00:05:45
|
On 10/29/06, Tom Denniston <tom...@al...> wrote: > > I recently upgraded to numpy 1.0 from 1.0b5. I noticed that numpy.argmaxbehavior is very strange on object arrays. See below: > > (Pdb) numpy.__version__ > '1.0' > (Pdb) numpy.argmax(numpy.array([2, 3], dtype=object)) > 0 > (Pdb) numpy.argmax(numpy.array([2, 3], dtype=int)) > 1 > (Pdb) numpy.argmax(numpy.array([2, 3], dtype=object), axis=0) > 0 > > > I would expect the argmax to behave the same on the dtype=int and > dtype=object examples but it doesn't. Am I missing some subtelty or is this > just a bug? 1.0 is the most recent version, right? > Suppose In [22]: array([1,[2,3]], dtype=object) Out[22]: array([1, [2, 3]], dtype=object) How would you compare the elements? In [27]: 2 < [0,0] Out[27]: True In [28]: [0,0] > 2 Out[28]: True Compares memory locations? In [28]: [2] < [0,0] Out[28]: False Lexical ordering? I don't know how python interprets these things. That said, I suspect your example should behave better, but it might give strange results sometimes anyway. Chuck |