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

Keys of dicts coming back in wrong type from HDF #220

Closed
aichhorn opened this issue May 7, 2015 · 4 comments
Closed

Keys of dicts coming back in wrong type from HDF #220

aichhorn opened this issue May 7, 2015 · 4 comments
Assignees

Comments

@aichhorn
Copy link
Member

aichhorn commented May 7, 2015

I want to store a dictionary in the archive, where the key is something more complicated, like a tuple.
d = {(1,2) : 1}
ar['d'] = d
When I retrieve it from the archive, the key is not a tuple but a string:
ar['d'] returns
d = {'(1,2)' : 1}
so it cannot be used as the original dictionary. Happens for instance for SK.sumk_to_solver.

@krivenko
Copy link
Contributor

Hello Markus,
I think, this issue looks more like a feature request.
Names of HDF5 groups and datasets have to be strings, and the Python dictionaries are stored as HDF5 groups. However, I can see a way around it. The non-string names could be simply represented by strings, and accompanied by small type tags (HDF5 attributes). These type tags would allow to correctly reconstruct the corresponding Python objects from the string form on loading.

@parcollet
Copy link
Member

Yes, it is possible. But that is one more thing to maintain.
Is it really necessary ?

@parcollet
Copy link
Member

@mferrero : opinion ?

@parcollet
Copy link
Member

H5 files are such that keys are strings. One should keep it this way,
or interaction with other projects like ALPS will be even more complex.

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

No branches or pull requests

3 participants