On 9/18/06, Bill Baxter <[EMAIL PROTECTED]> wrote:
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. 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.
Chuck
I find myself often wanting both the max and the argmax of an array.
(And same for the other arg* functions)
Of course I can do argmax first then use fancy indexing to get the max as well.
But the result of argmax isn't really in a format that's readily
usable as an index.
You have to do something like
a = rand(10,5)
imax = a.argmax(axis=0)
vmax = a[(imax, range(5))]
Which isn't terrible, just always takes me a moment to remember the
proper indexing _expression_.
Would a way to get the argmax and the max at the same time be of
interest to anyone else? Maybe an extra 'ret' arg on argmax?
a = rand(10,5)
imax,vmax = a.argmax(axis=0,retmax=True)
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. 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.
Chuck
------------------------------------------------------------------------- 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