Open HugoStrand opened 7 years ago
Hi Hugo, This issue was discussed before, see https://github.com/TRIQS/triqs/issues/220.
Dear Igor, Thanks for pointing this out.
Even so, I really think that HDFArchive should complain when the keys are not strings and throw an error.
In the current state one easily spends a couple of hours debugging, since the conversion is silent.
Best, H
Even so, I really think that HDFArchive should complain when the keys are not strings and throw an error.
In the current state one easily spends a couple of hours debugging, since the conversion is silent.
I agree, there is an issue that should be addressed.
The actual problem is that either of the potential solutions has its downside. Attaching type information to the keys will make archive format more complex. On the other hand, throwing an exception will surely break some codes. For example, I can easily imagine people using integers as dictionary keys.
Fair enough, so a deprecation warning printout would be the middle ground solution?
Fair enough, so a deprecation warning printout would be the middle ground solution?
Yes, this is probably the most reasonable thing we can do at the moment.
I was surprised to find that
pytriqs.archive.HDF5Archive
silently converts all keys in python dictionaries to strings, which of course break things expecting other python objects. See below for a small example.I would strongly recommend that conversion of dictionaries either are fully supported, or that one gets an error when trying to store a dictionary with non-string keys. Silent conversion is very bad practice.
Best, Hugo
Here is a small example:
resulting in