[Numpy-discussion] sort bug

Anton Sherwood bronto@pobox....
Thu Apr 26 01:34:07 CDT 2007


This code --

	adj = [ [eval(y) for y in x.split()] for x in infile ]
	val,vec = numpy.linalg.eig(adj)
	master = zip( val, vec.transpose() )
	master.sort()

*sometimes* gives this error:

	Traceback (most recent call last):
	  File "3work.py", line 14, in <module>
	    master.sort()
	ValueError: The truth value of an array with more
	than one element is ambiguous. Use a.any() or a.all()

What does sort() care about truth values?!

numpy.linalg.eig() sometimes returns complex values, which may not have 
a natural ordering, but I get this error (sometimes) even when it 
returns reals.

-- 
Anton Sherwood, http://www.ogre.nu/
"How'd ya like to climb this high *without* no mountain?" --Porky Pine


More information about the Numpy-discussion mailing list