[Numpy-discussion] casting homogeneous struct arrays

Simon Burton simon at arrowtheory.com
Mon May 22 01:03:01 EDT 2006


On Mon, 22 May 2006 01:47:38 -0600
Travis Oliphant <oliphant.travis at ieee.org> wrote:

> 
> 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? 

with shape = (1,3).

I am visualizing the fields as columns, and when
the array is homogeneous it seems natural to be able to switch between the
two array types.

Simon.

-- 
Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Australia
Ph. 61 02 6249 6940
http://arrowtheory.com 




More information about the NumPy-Discussion mailing list