[Numpy-discussion] argmax()
Alan G Isaac
aisaac at american.edu
Tue Jan 2 09:04:03 EST 2007
On Mon, 1 Jan 2007, Niklas Saers apparently wrote:
> If it makes any sense I'd love to send you this variable
> that had len(2048) but was very much longer if stomped
> flat. :-)
It looks like you may already understand this,
but just in case...
import numpy
r = numpy.random.random((100,5))
m1, m2 = numpy.argmax(r), r.argmax()
print m1, m2
print r.flat[m1], r.flat[m2]
try:
print r[m1], r[m2]
except:
print "oops!"
Cheers,
Alan Isaac
More information about the NumPy-Discussion
mailing list