import numpy as np
import h5py

filename = "test_vlen_datasets_np_bool.h5"

rows = [np.array([np.True_, np.False_]),
        np.array([np.True_, np.True_, np.False_])]

f = h5py.File(filename, 'x')  # create file, fails if exists

vlen_data_type = h5py.special_dtype(vlen=np.bool_)
dset = f.create_dataset("vlen_matrix", (2,),
                        compression="gzip",
                        compression_opts=9,
                        fletcher32=True,
                        dtype=vlen_data_type)


for r in range(len(rows)):
    dset[r] = rows[r]

f.flush()
f.close()

f = h5py.File(filename, 'r')
dsetr = f["vlen_matrix"]

for r in range(dsetr.shape[0]):
    print(dsetr[r])

[((9, 4, 9, 28), 'h5py.File', 'h5py.File', ({(9, 14, 9, 22): 'filename', (9, 24, 9, 27): '"""x"""'}, {}), "(filename, 'x')", False, 'import h5py\n'), ((11, 17, 11, 50), 'h5py.special_dtype', 'h5py.special_dtype', (), '', False, 'import h5py\n'), ((25, 4, 25, 28), 'h5py.File', 'h5py.File', ({(25, 14, 25, 22): 'filename', (25, 24, 25, 27): '"""r"""'}, {}), "(filename, 'r')", False, 'import h5py\n'), ((6, 8, 6, 39), 'numpy.array', 'np.array', ({(6, 17, 6, 38): '[np.True_, np.False_]'}, {}), '([np.True_, np.False_])', True, 'import numpy as np\n'), ((7, 8, 7, 49), 'numpy.array', 'np.array', ({(7, 17, 7, 48): '[np.True_, np.True_, np.False_]'}, {}), '([np.True_, np.True_, np.False_])', True, 'import numpy as np\n')]