[Numpy-discussion] Problem with array assignment

Todd Miller jmiller at stsci.edu
Wed Nov 2 14:17:24 CST 2005


I added support for the newcore "array interface" to the numarray C-API 
and this exception is now gone.  The fix/enhancement is checked into 
CVS.   Kick it around some...

Todd

Francesc Altet wrote:

>Hi,
>
>I've recently upgraded to Numeric 24.0 and numarray 1.4.1 and I'm
>having a problem that did not exist before:
>
>  
>
>>>>import Numeric
>>>>import numarray
>>>>Numeric.__version__
>>>>        
>>>>
>'24.0'
>  
>
>>>>numarray.__version__
>>>>        
>>>>
>'1.4.1'
>  
>
>>>>na=numarray.zeros((3,),'f')
>>>>num=Numeric.zeros((3,),'f')
>>>>na[...] = num
>>>>        
>>>>
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>ValueError: array sizes must be consistent.
>
>but...
>
>  
>
>>>>na=numarray.zeros((3,),'i')
>>>>num=Numeric.zeros((3,),'i')
>>>>na[...] = num
>>>>na
>>>>        
>>>>
>array([0, 0, 0])
>
>?????
>
>However, using Numeric 23.8 and numarray 1.3.3:
>
>  
>
>>>>import Numeric
>>>>import numarray
>>>>Numeric.__version__
>>>>        
>>>>
>'23.8'
>  
>
>>>>numarray.__version__
>>>>        
>>>>
>'1.3.3'
>  
>
>>>>na=numarray.zeros((3,),'f')
>>>>num=Numeric.zeros((3,),'f')
>>>>na[...] = num
>>>>na
>>>>        
>>>>
>array([ 0.,  0.,  0.], type=Float32)
>
>I don't know if the problem is coming from Numeric or numarray, but it
>only happens when one mix both:
>
>  
>
>>>>Numeric.__version__
>>>>        
>>>>
>'24.0'
>  
>
>>>>numarray.__version__
>>>>        
>>>>
>'1.4.1'
>  
>
>>>>na=numarray.zeros((3,),'f')
>>>>na2=numarray.zeros((3,),'f')
>>>>na2[...] = na
>>>>na2
>>>>        
>>>>
>array([ 0.,  0.,  0.], type=Float32)
>  
>
>>>>num=Numeric.zeros((3,),'f')
>>>>num2=Numeric.zeros((3,),'f')
>>>>num2[...] = num
>>>>num
>>>>        
>>>>
>array([ 0.,  0.,  0.],'f')
>
>Perhaps the new array protocol is involved here?
>
>  
>





More information about the Numpy-discussion mailing list