I found h5py allows one to create a dataset with zero-sized dimension.
For example,
h5f = h5py.File(“dummy.h5”, ‘w’)
buf = np.empty(shape=(2,0))
ds = h5f.create_dataset(’/var1’, data=buf)
But h5py does not allow to create a compound data type with zero-sized dimension. Is this feature not supported yet? I am using h5py 3.1.0.
The codes below error out at h5f.create_dataset().
dt = np.dtype([(‘x’, ‘float’, (2,0))])
ds = h5f.create_dataset(’/var2’, dtype=dt, data=(buf))
The error messages are:
Traceback (most recent call last):
File “./create_hdf5.py”, line 14, in main
ds = h5f.create_dataset(’/var2’, dtype=dt, data=(buf))
File “/python3.6/site-packages/h5py/_hl/group.py”, line 148, in create_dataset
dsid = dataset.make_new_dset(group, shape, dtype, data, name, **kwds)
File “/python3.6/site-packages/h5py/_hl/dataset.py”, line 89, in make_new_dset
tid = h5t.py_create(dtype, logical=1)
File “h5py/h5t.pyx”, line 1629, in h5py.h5t.py_create
File “h5py/h5t.pyx”, line 1653, in h5py.h5t.py_create
File “h5py/h5t.pyx”, line 1680, in h5py.h5t.py_create
File “h5py/h5t.pyx”, line 1586, in h5py.h5t._c_compound
File “h5py/h5t.pyx”, line 1653, in h5py.h5t.py_create
File “h5py/h5t.pyx”, line 1685, in h5py.h5t.py_create
File “h5py/h5t.pyx”, line 1477, in h5py.h5t._c_array
File “h5py/_objects.pyx”, line 54, in h5py._objects.with_phil.wrapper
File “h5py/_objects.pyx”, line 55, in h5py._objects.with_phil.wrapper
File “h5py/h5t.pyx”, line 330, in h5py.h5t.array_create
ValueError: Zero-sized dimension specified (zero-sized dimension specified)