Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Short
This is a demo code for having nested NPZ files.
What ?
When a dict variable with only str keys is given to np.savez, it is not converted to array of dtype=object nor pickled but rather used to create a child npz file that will be embedded in the parent npz file.
Of course that can be recursive.
Why ?
Comments
The writing part (modification of function _savez + new function _is_valid_dict ) is quite clean.
The reading part (modification of class NpzFile) can gain in quality, but that would mean deeper changes int the way getitem handles field types and in the way the class handles its parent zip file: currently we can't pass a byte stream to the NpzFile constructor but only a real file, that induces the use of temp files when having nested npz files.