Module Table :: Class Table
[show private | hide private]
[frames | no frames]

Type Table

object --+    
         |    
      Leaf --+
             |
object --+   |
         |   |
     Table --+
             |
            Table


Represents a table in the object tree.


Method Summary
  __getitem__(self, key)
Return a table row, table slice or table column.
  read(self, start, stop, step, field, flavor, coords)
Read a range of rows and return an in-memory object.
    Inherited from Table
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
    Inherited from Leaf
  __len__(self)
Useful for dealing with Leaf objects as sequences
  __str__(self)
The string reprsentation choosed for this object is its pathname in the HDF5 object tree.
  close(self, flush)
Flush the buffers and close this object on tree
  copy(self, where, name, title, filters, copyuserattrs, start, stop, step, overwrite)
Copy this leaf to other location where -- the group where the leaf will be copied.
  delAttr(self, attrname)
Delete a leaf attribute as a string
  flush(self)
Save whatever remaining data in buffer
  getAttr(self, attrname)
Get a leaf attribute as a string
  remove(self)
Remove a leaf
  rename(self, newname)
Rename a leaf
  setAttr(self, attrname, attrvalue)
Set a leaf attribute as a string
    Inherited from object
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Property Summary
    Inherited from Leaf
  attrs: Attrs of this object
  title: Title of this object

Method Details

__getitem__(self, key)
(Indexing operator)

Return a table row, table slice or table column.

It takes different actions depending on the type of the key parameter:

If key is an integer, the corresponding table row is returned as a Record or NestedRecord object, whatever is more appropriate. If key is a slice, the row slice determined by key is returned as a RecArray or NestedRecArray object, whatever is more appropriate.

Finally, if key is a string, it is interpreted as a column name in the table, and, if it is a plain field (i.e. has not a nested structure), it is read and returned as a NumArray or CharArray object (whatever is appropriate). If the column has a nested structure (nested column), it returns a NestedRecArray. If key has a '/' character on it, this is interpreted as a separator for nested fields (see examples).

Example 1

Get table row #0:

>>> table[0]
array(
[(1, (0.5, 1.0), ('a1', 1j))],
formats=['Int64', '(2,)Float32', ['a2', 'Complex64']],
shape=1,
names=['id', 'pos', ('info', ['name', 'value'])])

Example 2

Get a range of rows in table:

>>> table[:]
array(
[(1, (0.5, 1.0), ('a1', 1j)),
 (2, (0.0, 0.0), ('a2', 1+.1j))],
formats=['Int64', '(2,)Float32', ['a2', 'Complex64']],
shape=2,
names=['id', 'pos', ('info', ['name', 'value'])])

Example 3

Get a non-nested column:

>>> table['id']
array([1, 2], type=Int64)

Example 4

Get a nested column:

>>> table['info']
array(
[('a1', 1j),
 ('a2', 1+.1j)],
formats=['a2', 'Complex64'],
shape=2,
names=['info', ['name', 'value']])

Example 5

Get a deeply nested column:

>>> table['info/value']
array([ 0.+1.j ,  1.+0.1j])

read(self, start=None, stop=None, step=None, field=None, flavor='numarray', coords=None)

Read a range of rows and return an in-memory object.

If start, stop, or step parameters are supplied, a row range is selected.

If field is specified, this field name is returned as a NumArray object in case the column is a simple type. If field is a column with a type with structure (nested type), a NestedRecArray is returned instead.

If both field and flavor are provided and field refers to a column with a simple type (i.e. non-nested), an additional conversion to an object of this flavor is made. flavor must have any of the next values: 'numarray', 'Numeric', 'Tuple' or 'List'.

If field is not supplied then all the fields are selected and a RecArray (or a NestedRecArray, whatever is more appropriate) is returned.

If a coords list is specified, only the indices in coords that are in the range of (start , stop) are returned. step only can be assigned to be 1, otherwise an error is issued.

Example 1

Get table row #0:

>>> table.read(0)
array(
[(1, (0.5, 1.0), ('a1', 1j))],
formats=['Int64', '(2,)Float32', ['a2', 'Complex64']],
shape=1,
names=['id', 'pos', ('info', ['name', 'value'])])

Example 2

Get a range of rows in table:

>>> table.read(start=0, stop=table.nrows)
array(
[(1, (0.5, 1.0), ('a1', 1j)),
 (2, (0.0, 0.0), ('a2', 1+.1j))],
formats=['Int64', '(2,)Float32', ['a2', 'Complex64']],
shape=2,
names=['id', 'pos', ('info', ['name', 'value'])])

Example 3

Get a non-nested column:

>>> table.read(field='id')
array([1, 2], type=Int64)

Example 4

Get a nested column:

>>> table.read(field='info')
array(
[('a1', 1j),
 ('a2', 1+.1j)],
formats=['a2', 'Complex64'],
shape=2,
names=['info', ['name', 'value']])

Example 5

Get a deeply nested column:

>>> table.read(field='info/value')
array([ 0.+1.j ,  1.+0.1j])

Generated by Epydoc 2.1 on Thu Apr 21 13:11:50 2005 http://epydoc.sf.net