Dear Numpy list:
We've been using the numpy.rec classes to make record array objects.
We've noticed that in more recent versions of numpy, record-array like
objects can be made directly with the numpy.ndarray class, by passing a
complex data type.
However, it looks like the numpy.rec class is still supported.
So, we have a couple of questions:
1) Which is the preferred way to make a record array, numpy.rec, or the
numpy.ndarray with complex data type? A somewhat detailed explanation of
the comparative properties would be great. (We know it's buried somewhere
in the document ... sorry for being lazy!)
2) The individual "records" in numpy.rec array have the "numpy.record"
type. The individual records in the numpy.array approach have "numpy.void"
type. Can you tell us a little about how these differ, and what the
advantages of one vs the other is?
3) We've heard talk about "complex data types" in numpy in general. Is
there some good place we can read about this more extensively?
Also: one thing we use and like about the numpy.rec constructors is that
they can take a "names" argument, and the constructor function does some
inferring about what the formats you want are, e.g.:
img = numpy.rec.fromrecords([(0,1,'a'),(2,0,'b')], names =
['A','B','C'])
produces:
rec.array([(0, 1, 'a'), (2, 0, 'b')], dtype=[('A', '<i4'), ('B',
'<i4'), ('C', '|S1')])
This is very convenient.
My immediate guess for the equivalent thing with the numpy.ndarray approach:
img = numpy.array([(0,1,'a'),(2,0,'b')], names = ['A','B','C'])
does not work. Is there some syntax for doing this?
Thanks,
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090626/2a27d895/attachment.html