[Numpy-discussion] record array question

Russell E. Owen rowen@uw....
Wed Jul 15 13:26:57 CDT 2009


In article <rowen-1FF89A.11051515072009@news.gmane.org>,
 "Russell E. Owen" <rowen@uw.edu> wrote:

> Is it straightforward to generate a record array (preferably a standard 
> numpy.ndarray, not the numpy.rec variant) where some named fields 
> contain pairs of numbers, for example:
> 
> named field pos contains pairs of floats
> named field rot contains floats
> 
> Any pointers to relevant documentation would be appreciated. I found a 
> basic intro to record arrays on the scipy web site (which was quite 
> useful for generating simple record arrays), and the numpy book has a 
> bit of info, but I've not found anything very comprehensive.
> 
> -- Russell

Never mind. I found it today based on a posting; the kind of array I was 
interested in is a "structured array" and using that term the docs are 
easy to find, e.g.:
<http://docs.scipy.org/doc/numpy/user/basics.rec.html>

In particular:
numpy.zeros(shape, dtype=[("pos", float, (2,)), ("rot", float)])

-- Russell



More information about the NumPy-Discussion mailing list