Trees | Index | Help |
---|
Module nestedrecords :: Class NestedRecord |
|
Record
--+
|
NestedRecord
Nested record.
This is a generalization of the numarray.records.Record class to
support nested fields. It represents a record in a NestedRecArray
or an isolated record. In the second case, its names are
automatically set to c1, c2 etc. on each nested field.
This class is compatible with Record. However, getting a field
may return a NestedRecord
instead of a Python scalar, NumArray
or CharArray, if the field is nested.
Fields and sub-fields can be accessed using both the field()
method and the fields interface, which allows accessing fields
as Python attributes: nfld = nrec.fields.f1.fields.subf1[4].
The field()
method supports the '/' separator to access
sub-fields.
Nested recors can be converted to ordinary records by using the
asRecord()
method.
Method Summary | |
---|---|
__init__(self,
input,
row)
| |
Convert a nested record to a non-nested equivalent record. | |
Get field data. | |
Set field data. | |
Inherited from Record | |
Print one row. | |
Set the field data of the record. |
Method Details |
---|
asRecord(self)Convert a nested record to a non-nested equivalent record. This function creates a new vanilla Record instance equivalent to this one by flattening its fields. Only bottom-level fields are included in the array. The data area of the record is copied into the new one. ExampleLet us take the following nested record: >>> nr = NestedRecord([1, (0, 0), ('a1', 1j)]) Calling nr.asRecord() would return the same record as calling: >>> r = numarray.records.Record([1, (0, 0), 'a1', 1j]) Please note that the shape of multi-dimensional fields is kept. |
field(self, fieldName)Get field data. If the named field (
|
setField(self, fieldName, value)Set field data. Sets the field indicated by
|
Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Thu Apr 21 13:11:49 2005 | http://epydoc.sf.net |