Returns nothing
AmjadHD opened this issue · 1 comments
AmjadHD commented
I tried to open this file using this library:
import pkg/nimhdf5
let h5f = H5open("testset.hdf5", "r")
for item in h5f.items():
echo item
discard h5f.close()
but I get nothing.
when using h5py
:
import h5py
h5f = h5py.File("testset.hdf5", "r")
for item in h5f.items():
print(item)
h5f.close()
I get:
('X_test', <HDF5 dataset "X_test": shape (200, 64, 64), type "|u1">)
('Y_test', <HDF5 dataset "Y_test": shape (200, 1), type "<f8">)
Notes:
- It shows a warning about compiling without blosc support
- tried setting
-d:H5_FUTURE
, doesn't change anything. - nimhdf5: 0.5.1
- hdf5.dll: 1.10.8 (the same as for h5py)
- Nim: 1.9.1 and 1.6.4
- h5py: 3.7.0
- python: 3.11.0
Vindaar commented
You can't assume that nimhdf5
works exactly like h5py
. Groups and datasets are represented using different types. So the default items
iterator never yields datasets, it only yields groups!
If you really want the datasets from an iterator, you first need to get the root group and then call items
on that.
import nimhdf5
let h5f = H5open("/t/testset.hdf5", "r")
let root = h5f["/".grp_str]
for dset in root:
echo dset
discard h5f.close()
There are other important differences between h5py and nimhdf5 though, all essentially related to type safety. Better ping me on matrix/discord, as lately and in the near future I won't be looking at Github much.