Skip to content
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

Merged
merged 3 commits into from
May 4, 2022
Merged

Added support for .npy and .npz files. #358

merged 3 commits into from
May 4, 2022

Conversation

Pan-Maciek
Copy link
Contributor

Added support for NPZ file format.

@Pan-Maciek Pan-Maciek mentioned this pull request Apr 28, 2022
@codecov
Copy link

codecov bot commented Apr 28, 2022

Codecov Report

Merging #358 (b5ebdc3) into master (21f435d) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #358   +/-   ##
=======================================
  Coverage   87.50%   87.50%           
=======================================
  Files          10       10           
  Lines         696      696           
=======================================
  Hits          609      609           
  Misses         87       87           
Impacted Files Coverage Δ
src/registry.jl 93.22% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21f435d...b5ebdc3. Read the comment docs.

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])
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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:

  1. check the extension .npz
  2. check if the first few bytes match the magic bytes registered for .npz format.
  3. if not, return Format{:UNKNOWN} or error.

Copy link
Contributor Author

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.
@Pan-Maciek Pan-Maciek marked this pull request as ready for review May 3, 2022 18:58
@johnnychen94 johnnychen94 merged commit d3d941e into JuliaIO:master May 4, 2022
@ViralBShah ViralBShah mentioned this pull request Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants