[Numpy-discussion] sort bug

Charles R Harris charlesr.harris@gmail....
Thu Apr 26 14:05:23 CDT 2007


On 4/26/07, Anton Sherwood <anton.sherwood@gmail.com> wrote:
>
> Travis Oliphant wrote:
> > cmp(x,y) must return -1, 0, or 1 which doesn't work on arrays with more
> > than 1 element because it is ambiguous.  Thus you get this error.
>
> Ah.  Since lists *can* be compared, I assumed arrays would inherit
> that property.
>
> > The operation is undefined.  What do you actually want to do when you
> > have equal-valued eigenvalues?
>
> Don't care.
>
> All I really need is the four highest eigenvalues and their vectors.
> I'll have a look in "Python Cookbook" to see if there's a more
> efficient way to do that partial sort.


I don't think there are any partial sorts available. I think the best
approach in this case an argsort on the eigenvalues, followed by a take
using the last four resulting indexes would be the way to go.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070426/81bfcf91/attachment.html 


More information about the Numpy-discussion mailing list