[Numpy-discussion] Problem with array assignment

Francesc Altet faltet at carabos.com
Wed Nov 2 05:08:06 EST 2005


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?

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"





More information about the NumPy-Discussion mailing list