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.
|
| 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.
Is it always a gzip file here? If so might be worth using the gzip magic bytes.
There was a problem hiding this comment.
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.
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
.npzformat. - if not, return
Format{:UNKNOWN}or error.
There was a problem hiding this comment.
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.