2009/8/6 Hans Meine <me...@informatik.uni-hamburg.de>: > On Wednesday 05 August 2009 22:06:03 David Goldsmith wrote: >> But you can "cheat" and put them on one line (if that's all you're after): >> >>> x = np.array([1, 2, 3]) >> >>> maxi = x.argmax(); maxv = x[maxi] > > Is there any reason not to put this as a convenience function into numpy? > It is needed so frequently, and it's a shame that the shortest solution > traverses the array twice (the above is usually longer due to variable names, > and/or >1 dimensions).
The array is only traversed once. Indexing is O(1). I'm -1 on adding a function to do this. If you want to keep that convenience function in your own utilities, great. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion