[Numpy-tickets] [NumPy] #322: Shape mismatch error in rec.fromarray() constructor

NumPy numpy-tickets at scipy.net
Thu Oct 5 10:50:04 CDT 2006


#322: Shape mismatch error in rec.fromarray() constructor
--------------------+-------------------------------------------------------
 Reporter:  faltet  |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  normal  |   Milestone:          
Component:  Other   |     Version:          
 Severity:  normal  |    Keywords:          
--------------------+-------------------------------------------------------
 A strange error follows. The next works just fine:

 {{{

 In [102]:x1=numpy.array([[1,2],[3,4]])
 In [103]:x2=numpy.array(['a','dd'])
 In [104]:x3=numpy.array([1.1,2])
 In [105]:numpy.rec.fromarrays([x1,x2,x3], formats="(2,)i4,a3,f8")
 Out[105]:
 recarray([(array([1, 2]), 'a', 1.1000000000000001), (array([3, 4]), 'dd',
 2.0)],
       dtype=[('f1', '<i4', (2,)), ('f2', '|S3'), ('f3', '<f8')])
 }}}

 But:

 {{{
 In [109]:x1=numpy.array([[1,2],[3,4],[5,6]])
 In [110]:x2=numpy.array(['a','dd','xyz'])
 In [111]:x3=numpy.array([1.1,2,3])
 In [112]:numpy.rec.fromarrays([x1,x2,x3], formats="(2,)i4,a3,f8")
 ---------------------------------------------------------------------------
 exceptions.ValueError                                Traceback (most
 recent call last)

 /home/faltet/python.nobackup/numpy/<ipython console>

 /usr/lib/python2.4/site-packages/numpy/core/records.py in
 fromarrays(arrayList, dtype, shape, formats, names, titles, aligned,
 byteorder)
     307
     308     for k, obj in enumerate(arrayList):
 --> 309         nn = len(descr[k].shape)
     310         if obj.shape[nn:] != shape:
     311             raise ValueError, "array-shape mismatch in array %s" %
 k

 ValueError: array-shape mismatch in array 1

 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/322>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list