In h5py, what is type "|O"?

2.6k views Asked by At

Debugging a program working with h5py. The hdf5 should look something like this:

test.hdf5
    -labels <- DataSet
    -train <- Group

I do:

>>> import h5py
>>> test = h5py.File('test.hdf5')
>>> test['labels']
<HDF5 dataset "labels": shape (1, 2), type "|O">

What is type |O? I can't find it on the list of types or the special types.

1

There are 1 answers

0
hpaulj On BEST ANSWER

It's a reference.

implementing the example in that section:

In [275]: import h5py
In [276]: ref_dtype = h5py.special_dtype(ref=h5py.Reference)
In [278]: ref_dtype
Out[278]: dtype('O')

In [279]: f=h5py.File('test.h5','w')
In [281]: ref_dataset = f.create_dataset("MyRefs", (100,), dtype=ref_dtype)
In [282]: ref_dataset
Out[282]: <HDF5 dataset "MyRefs": shape (100,), type "|O">
In [283]: ref_dataset[:].dtype
Out[283]: dtype('O')