[Numpy-discussion] Empty arrays strange behaviour

Tim Hochberg tim.hochberg at cox.net
Wed Aug 18 07:24:02 CDT 2004


Nadav Horesh wrote:

>
>-----Original Message-----
>
>On Wed, 2004-08-18 at 07:36, Nadav Horesh wrote:
>  
>
>>>>>a = arange(20, shape=(4,5))
>>>>>a
>>>>>          
>>>>>
>>array([[ 0,  1,  2,  3,  4],
>>       [ 5,  6,  7,  8,  9],
>>       [10, 11, 12, 13, 14],
>>       [15, 16, 17, 18, 19]])
>>    
>>
>>>>>a[2:4,5:7]   # Shouldn't it raise index error?
>>>>>          
>>>>>
>>array([])
>>    
>>
>
>I wasn't sure about this,  but what we're doing is faithful to what
>Numeric does.
>
>[SNIP]
>
>
>I'd say we should go with compatibility.
>
>Todd
>
>  
>
Definately.

>It isn't a major flaw, so compatibility is OK.
>I got to this issue since I had a bug. If there was an option to get an IndexError exception it would ease the debugging.
>  
>
Please, no. In addition to breaking everybody's code, this change would 
make numarray's behaviour gratuitously different from the python list 
type as well as the numeric array type. In addition, the current 
behaviour does the Right Thing (TM) more often than not in the corner 
cases of algorithms.

-tim






More information about the Numpy-discussion mailing list