[Numpy-tickets] [NumPy] #313: Creating a recarray from columns with different shapes fails

NumPy numpy-tickets at scipy.net
Wed Oct 4 05:24:43 CDT 2006


#313: Creating a recarray from columns with different shapes fails
-----------------------+----------------------------------------------------
 Reporter:  faltet     |       Owner:  somebody   
     Type:  defect     |      Status:  new        
 Priority:  normal     |   Milestone:  1.0 Release
Component:  numpy.lib  |     Version:  devel      
 Severity:  normal     |    Keywords:             
-----------------------+----------------------------------------------------
 The next works well:

 {{{
 In [83]:numpy.rec.fromarrays([(1,2), ('red','green')],
 dtype=[('x','i4'),('color', 'a5')])
 Out[83]:
 recarray([(1, 'red'), (2, 'green')],
       dtype=[('x', '<i4'), ('color', '|S5')])
 }}}

 but, when trying to put together columns with different shapes, an error
 occurs:

 {{{
 In [84]:numpy.rec.fromarrays([((1,2),(2,3)), ('red','green')],
 dtype=[('x','(2,)i4'),('color', 'a5')])
 ---------------------------------------------------------------------------
 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)
     288     for obj in arrayList:
     289         if obj.shape != shape:
 --> 290             raise ValueError, "array has different shape"
     291
     292     if dtype is not None:

 ValueError: array has different shape
 }}}

 Note how the dtype in second case is adequate for columns with different
 shape.

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


More information about the Numpy-tickets mailing list