[Numpy-discussion] Yet another problem in CVS numarray

Todd Miller jmiller at stsci.edu
Thu Nov 10 09:54:36 EST 2005


Francesc Altet wrote:

>Ups, I've made a cvs update and not luck yet:
>
>  
>
>>>>import numarray; numarray.__version__
>>>>        
>>>>
>'1.4.2'
>  
>
>>>>import Numeric; Numeric.__version__
>>>>        
>>>>
>'24.1'
>  
>
>>>>num=Numeric.array([1,2,3,4])
>>>>numarray.array(num)
>>>>        
>>>>
>array([1, 2, 3, 4])
>  
>
>>>>num2=num[::2]
>>>>numarray.array(num2)
>>>>        
>>>>
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>  File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line 380, 
>in array
>    a = a.astype(type)
>  File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line 867, 
>in astype
>    return self.copy()
>  File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line 927, 
>in copy
>    c = _gen.NDArray.copy(self)
>  File "/usr/lib/python2.4/site-packages/numarray/generic.py", line 724, in 
>copy
>    arr._itemsize)
>numarray.libnumarray.error: copy4bytes: access beyond buffer. offset=11 
>buffersize=8
>
>I've made a rm -rf of old numarray extension, and rebuild everything
>from scratch.
>
>Regards,
>
>A Dijous 10 Novembre 2005 17:47, vàreu escriure:
>  
>
>>Francesc Altet wrote:
>>    
>>
>>>El dv 04 de 11 del 2005 a les 15:35 -0500, en/na Todd Miller va
>>>
>>>escriure:
>>>      
>>>
>>>>This turned out to be a problem with the way numarray handles Numeric's
>>>>multi-segment buffer protocol.   I worked around this by implementing
>>>>David Cooke's __array_struct__ array interface for numarray.
>>>>        
>>>>
>>>Did you commit the changes in CVS? I'm getting the same problems with
>>>
>>>the current CVS version:
>>>      
>>>
>>>>>>Numeric.__version__
>>>>>>            
>>>>>>
>>>'24.1'
>>>
>>>      
>>>
>>>>>>import numarray
>>>>>>numarray.__version__
>>>>>>            
>>>>>>
>>>'1.4.2'
>>>
>>>      
>>>
>>>>>>num=Numeric.array([1,2,3,4])
>>>>>>numarray.array(num)
>>>>>>            
>>>>>>
>>>array([1, 2, 3, 4])
>>>
>>>      
>>>
>>>>>>num2=num[::2]
>>>>>>numarray.array(num2)
>>>>>>            
>>>>>>
>>>Traceback (most recent call last):
>>> File "<stdin>", line 1, in ?
>>> File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line
>>>380, in array
>>>   a = a.astype(type)
>>> File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line
>>>867, in astype
>>>   return self.copy()
>>> File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line
>>>927, in copy
>>>   c = _gen.NDArray.copy(self)
>>> File "/usr/lib/python2.4/site-packages/numarray/generic.py", line 724,
>>>in copy
>>>   arr._itemsize)
>>>numarray.libnumarray.error: copy4bytes: access beyond buffer. offset=11
>>>buffersize=8
>>>      
>>>

So you're still seeing it?  Does the attached work for you?

Keep in mind,  anonymous CVS lags on Source Forge.

>>This turned out to be  a bug in numarray buffer size determination...
>>striding wasn't accounted for so the buffer appeared to be too small.
>>It's fixed now in CVS.  There's still a backward compatibility problem
>>for old Numerics which don't implement __array_struct__ and get
>>multi-segment buffers through __array_data__.
>>
>>Regards,
>>Todd
>>    
>>
>
>  
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: striding.py
Type: application/x-python
Size: 164 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20051110/d3fc1c76/attachment.bin>


More information about the NumPy-Discussion mailing list