[Numpy-discussion] Suppressing "nesting" (recursion, descent) in array construction.

Michael McNeil Forbes mforbes at physics.ubc.ca
Wed Jun 20 15:47:43 EDT 2007

Using take or array or similar operations on the initial list  
descends ignoring the tuples and converting the list to a multiple- 
dimension array:

 >>> take(keys,[1,0],axis=0)
array([['b', '2'],
        ['a', '1']],

It is sorted as I want, but I can no-longer use them as keys.  The  
problem can be solved by creating an empty array first, then copying.


> On 6/20/07, Michael McNeil Forbes <mforbes at physics.ubc.ca> wrote:
> Hi,
> I have a list of tuples that I am using as keys and I would like to
> sort this along with some other arrays using argsort.  How can I do
> this?  I would like to do something like:
> You might want the keys in an object array, otherwise you end up  
> with strings for all the values. Why are they keys? Do you want to  
> sort on them also? Anyway, if you use take(keys, inds, axis=0) you  
> will get an array with the rows containing the keys rearranged as I  
> think you want.
> Chuck

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070620/c5579165/attachment.html>

More information about the NumPy-Discussion mailing list