Christopher Barker wrote: > Hi folks, > > Someone on the wxPython list posted a nifty recarray example that I > don't quite understand. The idea is to have an array for an RGBA image: > > rgbarec = numpy.dtype({'r':(numpy.uint8,0), > 'g':(numpy.uint8,1), > 'b':(numpy.uint8,2), > 'a':(numpy.uint8,3)}) > > A = numpy.zeros(shape, dtype=(numpy.uint32, rgbarec) ) > > what I don't understand is having BOTH numpy.uint32 and rgbrec as the > dtype. How does that work? >
Basically, the rgbarec defines the fields, but the "base-type" for the numpy array is numpy.uint32 (rather than VOID which is the default data-type for arrays with fields defined). This is why it prints the way it does. I'm not sure what the real value is doing it that way as opposed to just having two views on the data: one as a uint32 and another as a "normal" recarray with a VOID data-type underlying it) like you suggest at the end. I think it's really just the "architecture" showing through to the user layer. -Travis _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion