[Numpy-tickets] [NumPy] #336: Creating new datatypes from existing ones

NumPy numpy-tickets at scipy.net
Thu Oct 12 06:23:05 CDT 2006

#336: Creating new datatypes from existing ones
 Reporter:  faltet       |       Owner:  somebody
     Type:  enhancement  |      Status:  new     
 Priority:  normal       |   Milestone:          
Component:  numpy.core   |     Version:          
 Severity:  normal       |    Keywords:          

 One thing that I believe would be quite useful (at least, it is for me),
 is to be able to create datatypes from pieces of other datatypes. An
 example would clarify this. Let's suppose that we have a generic nested

 In [35]:nt=numpy.dtype([('info', [('Name', '1a2'),('Value', '1c16')]),
    ....:        ('x', '(2, 2)f8'),
    ....:        ('y', '(2, 2)f8')])

 Now, I want to create a new datatype but using just cols 'info' and 'y'
 (i.e. remove the 'x' col). So, it would be nice if the next (or something
 equivalent) would work:

 In [40]:numpy.dtype([nt['info'], nt['y']])
 exceptions.TypeError                                 Traceback (most
 recent call last)

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

 TypeError: data type not understood


 Note that, for better reproducing the original column names, the dtype
 columns should keep their original name (see ticket:332).


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

More information about the Numpy-tickets mailing list