|
From: Travis O. <oli...@ee...> - 2006-02-01 22:16:54
|
I've just checked in some tests for the nested-record support in numpy. These tests were written by Francesc Alted and are very useful (they helped track down at-least two reference-counting errors). But, a big utility they have is to show a method for defining and constructing arrays of nested records. Anybody wanting to figure out how to use that facility in NumPy better would benefit by looking at the code in <site-packages>/numpy/core/tests/test_numerictypes.py in the SVN version of NumPy. -Travis P.S. Here is an example of the kind of structure he makes arrays of in this file... # This is the structure of the table used for nested objects (DON'T PANIC!): # # +-+---------------------------------+-----+----------+-+-+ # |x|Info |color|info |y|z| # | +-----+--+----------------+----+--+ +----+-----+ | | # | |value|y2|Info2 |name|z2| |Name|Value| | | # | | | +----+-----+--+--+ | | | | | | | # | | | |name|value|y3|z3| | | | | | | | # +-+-----+--+----+-----+--+--+----+--+-----+----+-----+-+-+ # After defining an array of these guys you could get at an array of y3 fields using a['Info']['Info2']['y3'] Or, reca = a.view(recarray) reca.Info.Info2.y3 -Travis |