[Numpy-discussion] default behavior of argsort

Dr. Phillip M. Feldman pfeldman at verizon.net
Fri May 14 17:03:46 EDT 2010




Robert Kern-2 wrote:
> 
> On Wed, May 12, 2010 at 20:19, Dr. Phillip M. Feldman
> <pfeldman at verizon.net> wrote:
>>
>> When operating on an array whose last dimension is unity, the default
>> behavior of argsort is not very useful:
>>
>> |6> x=random.random((4,1))
>> |7> shape(x)
>>                      <7> (4, 1)
>> |8> argsort(x)
>>                      <8>
>> array([[0],
>>       [0],
>>       [0],
>>       [0]])
>> |9> argsort(x,axis=0)
>>                      <9>
>> array([[0],
>>       [2],
>>       [1],
>>       [3]])
> 
> Sorry, but I don't think we are going to add a special case for this.
> 
> -- 
> Robert Kern
> 

I don't see this as a special case.  When axis is unspecified, the default
is axis=-1, which causes argsort to operate on the last dimension.  A more
sensible default would be the last non-unity dimension.

Phillip
-- 
View this message in context: http://old.nabble.com/default-behavior-of-argsort-tp28542476p28564261.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.




More information about the NumPy-Discussion mailing list