adds read_npz and write_npz, convenience wrappers
#46
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.
these work like
read_npyandwrite_npybut write compressed.npzfiles instead. I wanted this functionality for writing ephemeral array files to be able to check something later if needed without taking up too much disk space.in comparing to
read_npy/write_npy, there is one major difference: since anpzfile can contain multiple named arrays/files, this picks a default name for the single array it writes withwrite_npz, while allowing the user to specify the name to extract withread_npz. this may not be the best choice, but it seemed less than ideal to not permit specifying the name inread_npz, and I wantedwrite_npzto remain as simple as possible.I picked the default name for
write_npzbased on what numpy does insavez_compressed("arr_0.npy"). however, I think there is a divergence there. usingnp.load, you will get a dict-like object that allows you to access the arrays without the.npyextension (i.e. at keyarr_0). however, usingNpzReader, you need to use the fullarr_0.npyname to retrieve the same array. just wanted to flag as this tripped me up a bit.thanks for your consideration of this pull request.