[Numpy-discussion] Empty arrays strange behaviour
jmiller at stsci.edu
Wed Aug 18 08:31:05 EDT 2004
On Wed, 2004-08-18 at 11:16, Alan G Isaac wrote:
> >> I'd say we should go with compatibility.
> >> Todd
> a=[[i+i*j for i in range(5)]for j in range(4)]
> print a[2:4][5:7]
> import Numeric
> print b[2:4,5:7]
> import numarray
> print c[2:4,5:7]
> zeros((2, 0), 'l')
You've got something of a point here, if you're trying to say that
compatibility isn't perfect anyway.
Here's what I meant:
>>> from numarray import *
>>> a = arange(20)
>>> a.shape = (4,5)
class: <class 'numarray.numarraycore.NumArray'>
shape: (2, 0)
strides: (20, 4)
data: <memory at 0x404c0298 with size:0x00000050 held by object 0x401839c8 aliasing object 0x00000000>
The key points for me are:
1. The slice operation doesn't raise an exception even though it has
"invalid" indexes. As Tim H. pointed out, those are standard Python
2. The shape of the resultant array is the same.
I don't know anything about the purpose of "zeros()" in this context. It
looks inconsistent to me.
More information about the NumPy-Discussion