Документы для h5py.dataset
astype
метода:
astype(dtype)
Return a context manager allowing you to read data as a particular type. Conversion is handled by HDF5 directly, on the fly:
>>> dset = f.create_dataset("bigint", (1000,), dtype='int64')
>>> with dset.astype('int16'):
... out = dset[:]
>>> out.dtype
dtype('int16')
Обратите внимание, это не показывает dtype
astype
напрямую. astype
, примененный к массиву numpy, создает новый массив. Но с h5py
не совсем так работает.