|
Re: Re[2]: Empty arrays strange behaviour: msg#00057python.numeric.general
On Wed, 2004-08-18 at 11:16, Alan G Isaac wrote: > >> I'd say we should go with compatibility. > >> Todd > > > Script: > a=[[i+i*j for i in range(5)]for j in range(4)] > print a[2:4][5:7] > import Numeric > b=Numeric.array(a) > print b[2:4,5:7] > import numarray > c=numarray.array(a) > print c[2:4,5:7] > > Output: > [] > 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) >>> a[2:4,5:7] array([]) >>> a[2:4,5:7].info() class: <class 'numarray.numarraycore.NumArray'> shape: (2, 0) strides: (20, 4) byteoffset: 60 bytestride: 4 itemsize: 4 aligned: 1 contiguous: 0 data: <memory at 0x404c0298 with size:0x00000050 held by object 0x401839c8 aliasing object 0x00000000> byteorder: little byteswap: 0 type: Int32 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 semantics. 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. Regards, Todd ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re[2]: Empty arrays strange behaviour: 00057, Alan G Isaac |
|---|---|
| Next by Date: | Re: Empty arrays strange behaviour: 00057, Todd Miller |
| Previous by Thread: | Re[2]: Empty arrays strange behaviouri: 00057, Alan G Isaac |
| Next by Thread: | Re: Empty arrays strange behaviour: 00057, Todd Miller |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |