On 9/19/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > On 9/18/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > > I find myself often wanting both the max and the argmax of an array. > > (And same for the other arg* functions)
> > You have to do something like > > a = rand(10,5) > > imax = a.argmax(axis=0) > > vmax = a[(imax, range(5))] > > > I don't generally like overloading return values, the function starts to > lose its definition and becomes a bit baroque where simply changing a > keyword value can destroy the viability of the following code. Agreed. Seems like the only justification is if you get multiple results from one calculation but only rarely want the extra values. It doesn't make sense to always return them, but it's also not worth making a totally different function. > But I can see the utility of what you want. Hmm, this problem is not unique > to argmax. > Maybe what we need is a general way to extract values, something like > > extract(a, imax, axis=0) > > to go along with all the single axis functions. Yes, I think that would be easier to remember. It should also work for the axis=None case. imax = a.argmax(axis=None) v = extract(a, imax, axis=None) --Bill ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion