[Numpy-discussion] casting homogeneous struct arrays

Travis Oliphant oliphant.travis at ieee.org
Mon May 22 00:48:12 EDT 2006


Simon Burton wrote:
> This is something I will need to be able do:
>
>   
>>>> a=numpy.array( [(1,2,3)], list('lll') )
>>>>         
>>>> a.astype( 'l' )
>>>>         

Currently record-arrays can't be cast like this to built-in types.   
it's true the error message could be more informative.

What do you think should actually be done here anyway?  How do you want 
to cast 3 long's to 1 long? 

You can use the .view method to view a record-array as a different 
data-type without going through a data-copy using tostring and fromstring.

-Travis





More information about the NumPy-Discussion mailing list