hdfdict icon indicating copy to clipboard operation
hdfdict copied to clipboard

Example code is not running

Open campsd opened this issue 2 years ago • 2 comments

The example script shown in the readme does not appear to run. It throws a FileNotFoundError. Tested with h5py version 3.7.0:

FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = 'test_hdfdict.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

campsd avatar Oct 05 '22 05:10 campsd

I encountered the same error and didn't manage to solve it. Seems it is related to the importance of doing a f.close() command after opening a .h5 file as discussed in : https://github.com/h5py/h5py/issues/1066#issue-338414860

For your interest, I found this way of saving dictionary structure in h5 with h5py (pip install h5py), very useful and easy to reproduce : https://gist.github.com/gilliss/7e1d451b42441e77ae33a8b790eeeb73

Hope it helps, Thomas.

ThomasCoudert avatar Oct 13 '22 15:10 ThomasCoudert

Hi, I found a work around for this. I create a hdf5 file in the write mode and wrote the dict using hdfdict. Using the following code: save_file_path = 'sample.h5' f = h5py.File(save_file_path, 'w') hdfdict.dump(beam_temp, save_file_path) f.close()

Quantumstud avatar Nov 01 '22 23:11 Quantumstud

This is now solved by adding a mode default in the dump() and load() function. So it works as intended again. This error occured due to a change in h5py.

SiggiGue avatar May 24 '24 08:05 SiggiGue