***[Possible UCE]*** user-defined type example

Travis Oliphant oliphant.travis at ieee.org
Sat Oct 7 23:29:39 CDT 2006

Matt Knox wrote:
> Could someone please point me to/provide me with a basic example of 
> creating a user defined type?
> Here is my completely naive attempt which obviously doesn't work...
> import numpy
> class myType(numpy.void):
>     def __init__(self,val):
>         self.val = val
> testType = numpy.dtype(myType)
> val1 = myType(5)
> val2 = myType(6)
> foo = numpy.array([val1,val2],testType)
> Any help would be greatly appreciated. Thanks,

A "true" user-defined data-type can only be done in C.

However.  You can use the "VOID" data-type to create a type with 
multiple fields.   What do you want to do with your user-defined data-type.


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash

More information about the Numpy-discussion mailing list