A Thursday 10 February 2011 17:06:14 Francesc Alted escrigué:
> [A message from an unsubscribed (?) address]
> 
> De: Teemu Ikonen <tpiko...@gmail.com>
> A: pytables-users@lists.sourceforge.net
> Data: Avui 14:30:52
> 
> Hello,
> 
> I would need to store a set of variable-sized arrays inside another
> array (in effect giving each array an index). In Numpy terms my data
> is an array of dtype 'object', and the elements are Numpy (int32)
> arrays. Since array elements in HDF5 need to have a constant size,
> storing this kind of data with Pytables is not straightforward.
> 
> For example, if I write a similar array in Matlab to a HDF5 file
> (version 7.3 MAT-file) the element arrays are stored under a separate
> namespace ('/#refs#') with a random-looking dataset name. The array
> itself is filled with references to these objects. I could encode my
> data like this also in Python, but then saving and loading the
> original Numpy array would require special code to make and resolve
> the references.
> 
> Is there a standard and maybe even portable way of storing this kind
> of arrays in Pytables / HDF5?

The best way to do this in a portable way (i.e. native HDF5) is to use a 
VLArray object with (in your case) an Int32Atom().  The VLArray works 
very similar to an 'object' NumPy array, with the limitation that it 
cannot be multi-dimensional.  You can find more info about it in:

http://www.pytables.org/docs/manual/ch04.html#VLArrayClassDescr

and see some examples in examples/vlarray*.py

Hope that helps,

-- 
Francesc Alted

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to