Skip to content

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

Merged
johnnychen94 merged 3 commits into
JuliaIO:masterfrom
Pan-Maciek:NPZ
May 4, 2022
Merged

Added support for .npy and .npz files.#358
johnnychen94 merged 3 commits into
JuliaIO:masterfrom
Pan-Maciek:NPZ

Conversation

@Pan-Maciek

Copy link
Copy Markdown
Contributor

Added support for NPZ file format.

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

codecov Bot commented Apr 28, 2022

Copy link
Copy Markdown

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.

Comment thread src/registry.jl Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

3 participants