[Numpy-discussion] tuple vs. list as index

Travis Oliphant oliphant at ee.byu.edu
Fri May 13 11:21:29 EDT 2005


Todd Miller wrote:

>On Thu, 2005-05-12 at 17:04 -0700, Sebastian Haase wrote:
>  
>
>>Hi,
>>Is this really obvious to everybody:
>>
>>    
>>
>>>>>type(a)
>>>>>          
>>>>>
>><class 'numarray.numarraycore.NumArray'>
>>    
>>
>>>>>a.shape
>>>>>          
>>>>>
>>(12, 13, 2, 5)
>>    
>>
>>>>>a[(0,0)].shape
>>>>>          
>>>>>
>>(2, 5)
>>    
>>
>>>>>a[[0,0]].shape
>>>>>          
>>>>>
>>(2, 13, 2, 5)
>>
>>    
>>
>>>>>na.take(a,[0,0]).shape
>>>>>          
>>>>>
>>(2, 13, 2, 5)
>>
>>Is there some explanation in the documentation ? 
>>    
>>
>
>The distinction is not an accident and has been discussed.  One thing to
>keep in mind with numarray indexing is that not all sequences used as
>indices are created equal.   There is already a distinction for arrays
>used as indices,  and an additional distinction for Bool arrays used as
>  
>
>indices.  Back to basics, the explanation is this:
>  
>


This same distinction is kept in Numeric3 and currently works the same way.

Numeric3 should have the same semantics as Numarray.


-Travis





More information about the NumPy-Discussion mailing list