[Numpy-discussion] zero dimensions in numarray.strings?

Todd Miller jmiller at stsci.edu
Wed Dec 3 03:48:07 CST 2003


On Wed, 2003-12-03 at 05:08, Francesc Alted wrote:
> A Dimarts 02 Desembre 2003 12:52, Todd Miller va escriure:
> >
> > I fixed the immediate problem with zero element string arrays this
> > morning.  I imagine there are probably other problems with that case...
> > Please let me know if and when you find them.
> 
> Thanks. Well, I've found another small issue. The next works:
> 
> >>> array([]).info()
> class: <class 'numarray.numarraycore.NumArray'>
> shape: (0,)
> strides: (4,)
> byteoffset: 0
> bytestride: 4
> itemsize: 4
> aligned: 1
> contiguous: 1
> data: <memory at 40552060 with size:0 held by object 40552040 aliasing object 
> 00000000>
> byteorder: little
> byteswap: 0
> type: Int32
> 
> 
> But this don't:
> 
> >>> strings.array([])
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/local/lib/python2.3/site-packages/numarray/strings.py", line 964, 
> in array
>     return fromlist(buffer, itemsize=itemsize, shape=shape, kind=kind)
>   File "/usr/local/lib/python2.3/site-packages/numarray/strings.py", line 828, 
> in fromlist
>     shape, itemsize = _slistShape(slist, itemsize=itemsize, shape=shape)
>   File "/usr/local/lib/python2.3/site-packages/numarray/strings.py", line 763, 
> in _slistShape
>     shape_items = _slistShape0(slist)
>   File "/usr/local/lib/python2.3/site-packages/numarray/strings.py", line 746, 
> in _slistShape0
>     maxs = _slistShape0(slist[0])
> IndexError: list index out of range
> 
> Perhaps (?) you want to make it equivalent to:
> 
> >>> strings.array(None, shape=(0,), itemsize=0).info()
> class: <class 'numarray.strings.CharArray'>
> shape: (0,)
> strides: (0,)
> byteoffset: 0
> bytestride: 0
> itemsize: 0
> aligned: 1
> contiguous: 1
> data: <memory at 405521e0 with size:0 held by object 405521c0 aliasing object 
> 00000000>
> type: CharArrayType(0)
> 
> I've used the numarray present in CVS to run these test.

OK.  I appended this to the 'zero dimension string' bug report so that
it doesn't get lost.

Todd

-- 
Todd Miller <jmiller at stsci.edu>





More information about the Numpy-discussion mailing list