Trees | Index | Help |
---|
Module nestedrecords :: Class NestedRecArray |
|
object
--+ |_ndarray
--+ |NDArray
--+ |RecArray
--+ | NestedRecArray
Array of nested records.
This is a generalization of the numarray.records.RecArray class.
It supports nested fields and records via the NestedRecord
class.
This class is compatible with RecArray. However, part of its behaviour has been extended to support nested fields:
NestedRecord
,
a special kind of Record with support for nested structures.NestedRecArray
instead of an ordinary RecArray.NestedRecArray
instead of a
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: nrec = nrarr.fields.f1.fields.subf1[4].
The field()
method supports the '/' separator to access
sub-fields.
Nested record arrays can be converted to ordinary record arrays by
using the asRecArray()
method.
Finally, the constructor of this class is not intended to be used
directly by users. Instead, use one of the creation functions
(array()
, fromarrays()
or the others).
Method Summary | |
---|---|
__init__(self,
recarray,
descr)
| |
Convert a nested array to a non-nested equivalent array. | |
Get field data as an array. | |
Inherited from RecArray | |
Add two RecArray objects in a row wise manner | |
returns pickled state dictionary for RecArray | |
| |
restores state of NDArray after unpickling. | |
| |
Byteswap data in place and change the _byteorder attribute. | |
| |
info() prints out key attributes of a record array. | |
| |
reverses the state of the _byteorder attribute: little <-> big. | |
| |
Byteswap the data in place. | |
convert input field names into a list and assign to the _names attribute | |
Get a dictionary of fields as numeric arrays. | |
| |
Parse the field formats | |
| |
Inherited from NDArray | |
support for copy.copy() | |
support for copy.deepcopy() | |
| |
__reduce__ returns the pickling "reduction tuple" for an NDArray. | |
| |
Return a new array with the same shape and type, but a copy of the data | |
factory(...) calls the array(...) factory function defined in the source module where the class of 'self' was defined. | |
| |
| |
| |
is_c_array() returns 1 iff the array is aligned and contiguous, and returns 0 otherwise. | |
Size (in bytes) of an array element | |
| |
| |
ravel(self) setshapes 'self' into an equivalent 1D array. | |
repeat() returns a new array with each element 'a[i]' repeated 'r[i]' times. | |
resize() shrinks/grows 'self' to new 'shape', possibly replacing the underlying buffer object. | |
| |
Change array shape in place. | |
| |
Write the array as a binary image to a file. | |
Return a string with a binary copy of the array | |
transpose() re-shapes the array by permuting it's dimensions as specified by 'axes'. | |
| |
Return broadcast view of arr, else return None. | |
| |
Copy elements from another array. | |
Return broadcast views both self and arr, else return (None,None). | |
| |
| |
| |
Compute the strides from shape for a contiguous array | |
| |
Write the array to a file repeatedly in blocks | |
Inherited from _ndarray | |
x.__delitem__(y) <==> del x[y] | |
x.__getitem__(y) <==> x[y] | |
x.__len__() <==> len(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
x.__setitem__(i, y) <==> x[i]=y | |
byte offset of indices within array |
_getByteOffset(indices) -> byte offset of indices within array |
None |
_putter(axis1, axis2) -> None |
_simpleIndexing(key, value=None) gets or sets for integer sequence key | |
None |
_taker(axis1, axis2) -> None |
_universalIndexing(key, value=None) gets(value=None) or sets(value!=None) at key | |
1 if array is fortran-contiguous, 0 otherwise. |
is_fortran_contiguous() -> 1 if array is fortran-contiguous, 0 otherwise. |
1 if array is aligned, 0 otherwise. |
isaligned() -> 1 if array is aligned, 0 otherwise. |
1 if array is contiguous, 0 otherwise. |
iscontiguous() -> 1 if array is contiguous, 0 otherwise. |
total number of elements in array. |
nelements() -> total number of elements in array. |
total number of elements in array. |
nelements() -> total number of elements in array. |
None |
swapaxes(axis1, axis2) -> None |
array converted to nested list of scalars. |
tolist() -> array converted to nested list of scalars. |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value |
Property Summary | |
---|---|
Inherited from NDArray | |
flat : access to array as 1D | |
shape : tuple of array dimensions |
Class Variable Summary | |
---|---|
Inherited from _ndarray | |
getset_descriptor |
_aligned = <attribute '_aligned' of '_ndarray._ndarray' ...
|
getset_descriptor |
_byteoffset = <attribute '_byteoffset' of '_ndarray._nda...
|
getset_descriptor |
_bytestride = <attribute '_bytestride' of '_ndarray._nda...
|
getset_descriptor |
_contiguous = <attribute '_contiguous' of '_ndarray._nda...
|
getset_descriptor |
_data = <attribute '_data' of '_ndarray._ndarray' object...
|
getset_descriptor |
_itemsize = <attribute '_itemsize' of '_ndarray._ndarray...
|
getset_descriptor |
_shape = <attribute '_shape' of '_ndarray._ndarray' obje...
|
getset_descriptor |
_strides = <attribute '_strides' of '_ndarray._ndarray' ...
|
getset_descriptor |
flags = <attribute 'flags' of '_ndarray._ndarray' object...
|
getset_descriptor |
rank = <attribute 'rank' of '_ndarray._ndarray' objects>
|
Method Details |
---|
asRecArray(self)Convert a nested array to a non-nested equivalent array. This function creates a new vanilla RecArray instance equivalent to this one by flattening its fields. Only bottom-level fields are included in the array. Sub-fields are named by prepending the names of their parent fields up to the top-level fields, using '/' as a separator. The data area of the array is copied into the new one. ExampleLet us take the following nested array: >>> nra = array([(1, (0, 0), ('a1', 1j)), (2, (0, 0), ('a2', 2j))], ... names=['id', 'pos', ('info', ['name', 'value'])], ... formats=['Int64', '(2,)Float32', ['a2', 'Complex64']]) Calling nra.asRecArray() would return the same array as calling: >>> ra = numarray.records.array( ... [(1, (0, 0), 'a1', 1j), (2, (0, 0), 'a2', 2j)], ... names=['id', 'pos', 'info/name', 'info/value'], ... formats=['Int64', '(2,)Float32', 'a2', 'Complex64']) Please note that the shape of multi-dimensional fields is kept. |
field(self, fieldName)Get field data as an array. If the named field (
|
Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Thu Apr 21 13:11:50 2005 | http://epydoc.sf.net |