Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump objects into h5py.Group #54

Closed
siebenkopf opened this issue Oct 25, 2017 · 2 comments · Fixed by #117
Closed

Dump objects into h5py.Group #54

siebenkopf opened this issue Oct 25, 2017 · 2 comments · Fixed by #117

Comments

@siebenkopf
Copy link

I am trying to hickle objects into existing h5py.File objects and put each object into its own Group. Unfortunately, hickle does not allow me to do that.
Here is a minimal example:

import hickle, numpy, h5py
# open h5py file and create a group
h = h5py.File("test.hdf5", 'w')
h.create_group("Array")
# dump data into that group
d = numpy.ones((10,10))
hickle.dump(d, h["Array"])

which raises:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python2.7/site-packages/hickle.py", line 308, in dump
    h5f = file_opener(file_obj, mode, track_times)
  File ".../lib/python2.7/site-packages/hickle.py", line 163, in file_opener
    raise FileError
hickle.FileError: Cannot open file. Please pass either a filename string, a file object, or a h5py.File

I assume that it should be easy to also accept h5py.Group objects, as they have the same functionality as the h5py.File.

@telegraphic
Copy link
Owner

Thanks @siebenkopf , that is an excellent suggestion. There is currently some limited support using the path='/path/to/group', but frankly this isn't particularly well tested, and your use case is neat. Adding it to the todo list in #28!

@1313e
Copy link
Collaborator

1313e commented Oct 1, 2019

This has been fixed with the additions I made in #94.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants