The Table, Array, CArray, VLArray and EArray classes can all handle the complete set of data types supported by the numarray package (see []), NumPy (see []) and Numeric (see []) in Python. The data types for table fields can be set via the constructor for the Col class and its descendants (see 4.16.2) while array elements can be set through the use of the Atom class and its descendants (see 4.16.3).
In addition to those data types, PyTables' Table, VLArray and EArray classes do support some aliasing data types for their columns and atoms. Each one of these aliasing types corresponds to one numarray type, but they also have special meanings for PyTables. They can be seen as the ordinary types they are associated with, plus some additional meaning. Since they do not exist as numarray types, they can only be specified to PyTables using strings.
Currently, the only supported aliasing data type is Time. Two kinds of time values can be handled: 4-byte signed integer and 8-byte double precision floating point. Both of them reflect the number of seconds since the Unix Epoch, i.e. Jan 1 00:00:00 UTC 1970. Their types correspond to numarray's Int32 and Float64, respectively. Time values are stored in the HDF5 file using the H5T_TIME class. Integer times are stored as is, while floating point times are split into two signed integer values representing seconds and microseconds (beware: smaller decimals will be lost!).
PyTables also supports HDF5 H5T_ENUM enumerations (restricted sets of unique name and unique value pairs). The numarray representation of an enumerated value depends on the concrete base type used to store the enumeration in the HDF5 file. Enumerations are similar to aliasing data types in the sense that enumerated data is handled as regular numarray data. Enumerations are also specified to PyTables using a string type, with an additional Enum (see 4.17.4) instance.
Currently, only scalar integer values (both signed and unsigned) are supported in enumerations. This restriction may be lifted when HDF5 supports other kinds on enumerated values.
A quick reference to the complete set of data types supported by PyTables is given in table A.
Table A.1. Data types supported for array elements and tables columns in PyTables.
Type Code | Description | C Type | Size (in bytes) | Python Counterpart |
---|---|---|---|---|
Bool | boolean | unsigned char | 1 | Boolean |
Int8 | 8-bit integer | signed char | 1 | Integer |
UInt8 | 8-bit unsigned integer | unsigned char | 1 | Integer |
Int16 | 16-bit integer | short | 2 | Integer |
UInt16 | 16-bit unsigned integer | unsigned short | 2 | Integer |
Int32 | integer | int | 4 | Integer |
UInt32 | unsigned integer | unsigned int | 4 | Long |
Int64 | 64-bit integer | long long | 8 | Long |
UInt64 | unsigned 64-bit integer | unsigned long long | 8 | Long |
Float32 | single-precision float | float | 4 | Float |
Float64 | double-precision float | double | 8 | Float |
Complex32 | single-precision complex | struct {float r, i;} | 8 | Complex |
Complex64 | double-precision complex | struct {double r, i;} | 16 | Complex |
CharType | arbitrary length string | char[] | * | String |
Time32 | integer time | POSIX's time_t | 4 | Integer |
Time64 | floating point time | POSIX's struct timeval | 8 | Float |
Enum | enumerated value | enum | - | - |