"""Generate std_ref_hdf5_2_0.h5: a dataset of H5T_STD_REF (the reference datatype introduced in HDF5 1.12, datatype message version 4) holding two object references — to /target (a dataset) and /grp (a group). h5py has no API for this type, so the file is written by calling the libhdf5 bundled in the h5py wheel directly through ctypes. Written with h5py 3.16.0 / HDF5 2.0.0. Re-run only if the fixture ever needs regenerating: python gen_std_ref.py std_ref_hdf5_2_0.h5 """ import ctypes import glob import os import sys import h5py import numpy as np libdir = os.path.join(os.path.dirname(os.path.dirname(h5py.__file__)), "h5py.libs") libs = [p for p in glob.glob(os.path.join(libdir, "libhdf5*.so*")) if "_hl" not in os.path.basename(p)] lib = ctypes.CDLL(libs[0]) lib.H5open() hid = ctypes.c_int64 std_ref = hid.in_dll(lib, "H5T_STD_REF_g").value lib.H5Screate_simple.restype = hid lib.H5Screate_simple.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_uint64)] lib.H5Dcreate2.restype = hid lib.H5Dcreate2.argtypes = [hid, ctypes.c_char_p, hid, hid, hid, hid, hid] lib.H5Rcreate_object.argtypes = [hid, ctypes.c_char_p, hid, ctypes.c_void_p] lib.H5Dwrite.argtypes = [hid, hid, hid, hid, hid, ctypes.c_void_p] lib.H5Dclose.argtypes = [hid] with h5py.File(sys.argv[1], "w", libver="latest") as f: f.create_dataset("target", data=np.arange(5, dtype="