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

Todd Miller jmiller at stsci.edu
Tue Dec 2 03:54:03 CST 2003


On Tue, 2003-12-02 at 04:33, Francesc Alted wrote:
> Hi,
> 
> It seems like if numarray.strings module is not able to create objects when
> one of its dimensions is zero. For example, this works:
> 
> >>> import numarray
> >>> numarray.array([], shape=(1,0,2))
> array([])
> 
> but, for strings, it raises the next error:
> 
> >>> numarray.strings.array(None, itemsize=3, shape=(1,0,2))
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/local/lib/python2.3/site-packages/numarray/strings.py", line 955, 
> in array
>     byteoffset=byteoffset, bytestride=bytestride)
>   File "/usr/local/lib/python2.3/site-packages/numarray/strings.py", line 94, 
> in __init__
>     self.fill(" ")
>   File "/usr/local/lib/python2.3/site-packages/numarray/strings.py", line 318, 
> in fill
>     self[:] = char*self._itemsize
>   File "/usr/local/lib/python2.3/site-packages/numarray/generic.py", line 505, 
> in _slicedIndexing
>     retarr._copyFrom(value)
>   File "/usr/local/lib/python2.3/site-packages/numarray/strings.py", line 202, 
> in _copyFrom
>     me[:] = it[..., :self._itemsize]
>   File "/usr/local/lib/python2.3/site-packages/numarray/generic.py", line 505, 
> in _slicedIndexing
>     retarr._copyFrom(value)
> libnumarray.error: copy1bytes: access beyond buffer. offset=2 buffersize=0
> 
> I think it would be nice (and consistent) to support that in strings too.

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.


Regards,
Todd

> 
> Thanks,
-- 
Todd Miller <jmiller at stsci.edu>





More information about the Numpy-discussion mailing list