[Numpy-discussion] Yet another problem in CVS numarray

Todd Miller jmiller at stsci.edu
Fri Nov 4 12:36:58 CST 2005


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.  I'm now 
seeing times like these:

numarray-->Numeric array_if: [0.20523881912231445, 0.19724917411804199, 
0.17538094520568848]
numarray-->Numeric fromstring: [0.28353691101074219, 
0.21145009994506836, 0.22541189193725586]
Numeric-->numarray array_if: [0.40105700492858887, 0.34915614128112793, 
0.39094209671020508]
Numeric-->numarray buffer_if: [0.29201602935791016, 0.25055789947509766, 
0.23227095603942871]

As you can see,  the numarray-->Numeric array_if is now faster than 
fromstring() and Numeric-->numarray array_if is now getting close to the 
time for constructing a numarray from a buffer.

Todd

Francesc Altet wrote:

>Hi,
>
>I've detected another problem in CVS numarray when converting
>non-contiguous Numeric objects.
>
>With numarray 1.3.3 the next works:
>
>  
>
>>>>Numeric.__version__
>>>>        
>>>>
>'23.8'
>  
>
>>>>numarray.__version__
>>>>        
>>>>
>'1.3.3'
>  
>
>>>>num=Numeric.array([1,2,3,4],'b')
>>>>num2=num[::2]
>>>>num2.iscontiguous()
>>>>        
>>>>
>0
>  
>
>>>>na=numarray.array(num2)
>>>>na
>>>>        
>>>>
>array([1, 3])
>
>but, with CVS version of numarray:
>
>  
>
>>>>numarray.__version__
>>>>        
>>>>
>'1.4.2'
>  
>
>>>>Numeric.__version__
>>>>        
>>>>
>'24.1'
>  
>
>>>>na=numarray.array([1,2,3,4],'b')
>>>>num=Numeric.array([1,2,3,4],'b')
>>>>num2=num[::2]
>>>>num2.iscontiguous()
>>>>        
>>>>
>0
>  
>
>>>>na=numarray.array(num2)
>>>>        
>>>>
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>  File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line 376, 
>in array
>    a = a.astype(type)
>  File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line 863, 
>in astype
>    return self.copy()
>  File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line 923, 
>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: copy1bytes: access beyond buffer. offset=2 
>buffersize=2
>
>Cheers,
>
>  
>





More information about the Numpy-discussion mailing list