Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Nested compound types TypeError #1197
First of all, thank you for helping with the h5py package.
I believe I have encountered a bug related to nested compound data types. Below you can find a minimal example.
# create compound data d = np.dtype((('i', 2), 3)) a = np.arange(2*3).reshape((3,2)) data = np.array([tuple(a)], dtype=d) # a.shape = (1, 3, 2) # create dataset with h5py.File("test.h5") as fle: dset = fle.create_dataset( "test", shape=[1,], dtype=d, ) # dset.dtype = dtype((('<i4', (2,)), (3,))) dset[...] = data
The last line raises the error
Transposing the format
Instead, if I create the dataset with a different type, the write works without problems
dset = new_file.create_dataset( "test", shape=[1,], dtype=np.dtype(('i', (3, 2))), )
My version info is as follows
Looking at where it's failing, https://github.com/h5py/h5py/blob/master/h5py/_hl/dataset.py#L646 looks to be assuming that there is only one level of compound types. We could document that nested compound types are currently not supported, and that we'd accept a PR to support nested compound types (there are probably other changes needed other than that line, I don't think it's an easy fix).