-
Notifications
You must be signed in to change notification settings - Fork 21
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
[WIP] Adds h5py dump #221
base: serialization
Are you sure you want to change the base?
[WIP] Adds h5py dump #221
Conversation
elif isinstance(val, dict): | ||
group = f.create_group(key, track_order=True) | ||
recursive_save(val, group) | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we keep the elif isinstance statements going for the other types, incl. string and ndarrays? Better to be explicit. Maybe just call str() on types that do not match anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean like this? If we call str() on the else statement, then the numpy data structures won't be saved as numpy types
elif isinstance(val, dict):
group = f.create_group(key, track_order=True)
recursive_save(val, group)
elif isinstance(val, str):
f.create_dataset(key, data=val, dtype=dt, track_order=True)
else:
f.create_dataset(key, data=val, track_order=True)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but add an isinstance(val, np.ndarray) block in there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about the updated code?
...
self.supported_types = (bool, int, float, np.ndarray, np.integer, np.floating)
...
elif isinstance(val, self.supported_types):
f.create_dataset(key, data=val, track_order=True)
elif isinstance(val, str):
# specify string dtype to avoid issues with encodings
f.create_dataset(key, data=val, dtype=dt, track_order=True)
else:
f.create_dataset(key, data=str(val), track_order=True)
No description provided.