-
Notifications
You must be signed in to change notification settings - Fork 82
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
Added support for .npy and .npz files. #358
Conversation
Codecov Report
@@ Coverage Diff @@
## master #358 +/- ##
=======================================
Coverage 87.50% 87.50%
=======================================
Files 10 10
Lines 696 696
=======================================
Hits 609 609
Misses 87 87
Continue to review full report at Codecov.
|
src/registry.jl
Outdated
@@ -26,6 +27,8 @@ add_format(format"JLD2", (unsafe_wrap(Vector{UInt8},"Julia data file (HDF5), ver | |||
add_format(format"GZIP", [0x1f, 0x8b], ".gz", [:Libz => UUID("2ec943e9-cfe8-584d-b93d-64dcb6d567b7")]) | |||
add_format(format"BSON",(),".bson", [:BSON => UUID("fbb218c0-5317-5bc6-957e-2ee96dd4b1f0")]) | |||
add_format(format"JLSO", (), ".jlso", [:JLSO => UUID("9da8a3cd-07a3-59c0-a743-3fdc52c30d11")]) | |||
add_format(format"NPY", "\x93NUMPY", ".npy", [idNPZ]) | |||
add_format(format"NPZ", "", ".npz", [idNPZ]) |
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.
Is it always a gzip file here? If so might be worth using the gzip magic bytes.
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.
I just checked:
np.savez("test.npz", a=np.array([1,2,3]), b=np.array([1.2, 3.4]))
Generated file looks just like a plain .zip
file for me.
The file magic is just zip file magic "PK\x03\x04".
There is no comment in central directory to detect.
Idk if it would make sense as it might conflict with a zip files in the future.
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.
It's okay here, don't worry. FileIO queries the file/io format in the following order:
- check the extension
.npz
- check if the first few bytes match the magic bytes registered for
.npz
format. - if not, return
Format{:UNKNOWN}
or error.
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.
Ok, I added them.
Either way I'm waiting on NPZ to approve this MR before we can proceed. This is why I marked this as a draft.
It's just zip file magic.
Added support for NPZ file format.