[SciPy-User] argsort TypeError

Chris Weisiger cweisiger@msg.ucsf....
Thu Aug 9 12:54:17 CDT 2012

I'm trying to find the indices in an array that have the lowest
values, so that I can plot the corresponding values in another array.
numpy.argsort would seem to be the proper approach here, but when I
try it I get this error:

Traceback (most recent call last):
  File "../scripts/findWorstFitPixel.py", line 48, in <module>
    indices = np.argsort(result)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/fromnumeric.py",
line 680, in argsort
    return argsort(axis, kind, order)
TypeError: an integer is required

The weird thing is that when I try to replicate the circumstances in
the REPL (same argument shape/dtype passed to argsort), it succeeds.
So there must be something subtle going on here. My input is a
length-270336 1D array of float32s, each of which was generated by
scipy.stats.pearsonr and almost all of which have values between .95
and 1. Any ideas what I can investigate to get this working?
Unfortunately my script relies on reading a bunch of files, so I can't
very well upload a working sample, but the script itself is here:

Thanks for any assistance!


More information about the SciPy-User mailing list