Glen W. Mabey wrote: >On Thu, May 31, 2007 at 11:05:52AM -0600, Travis Oliphant wrote: > > >>Tobias Knopp wrote: >> >> >> >>>Hi! >>> >>>I was looking for a method to find the indices of the smallest element >>>of an 3-dimensional array a. Therefore i used >>> >>>a.argmax() >>> >>>The problem was, that argmax gives me a flat index. My question is, if >>>there is a build-in function to convert the flat index back to a >>>multidimensional one. I know how to write such a procedure but was >>>curious if one exists in numpy. >>> >>> >>See >> >>numpy.unravel_index >> >> > >When I first learned that the value returned by the argmax() function >consists of a ravel()ed index (when axis is not specified), I was >told that it makes perfect sense in that it is consistent with the behavior >of max() and other functions that assume a ravel()ed behavior when axis >isn't specified. > >While I have to agree that it does make sense (some note of this >behavior should probably be added to the docstrings ... ), I also feel >that is it not intuitive, and will almost universally lead to confusion >(initially) for those who use it. > >One could even argue that a ravel()ed index is not correct, in that it >cannot [immediately] be used as an argument that references the >indicated element. > >
It can be used as an argument using ind = x.argmax() x.flat[ind] -Travis _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
