JuliaIO / JLD2.jl

HDF5-compatible file format in pure Julia
Other
547 stars 85 forks source link

Add support for @unpack, @pack! for file-interface (+Test,Documentation) #455

Closed lukasgrunwald closed 1 year ago

lukasgrunwald commented 1 year ago

Add optional support for @unpack, @pack! from UnPack.jl for file-interface (see #454). They work for the normal file-interface and for JLD2.Group's. The feature can be used as

using JLD2, UnPack
file = jldopen("example.jld2", "w")
x, y = rand(2)

@pack! file = x, y # equivalent to file["x"] = x; file["y"] = y
@unpack x, y = file # equivalent to x = file["x"]; y = file["y"]

The new methods are only added if the user loads the UnPack package himself. This is implemented via Requires.jl. For Julia $\geq 1.9$ there are Package extensions, but since 1.9 is still in beta, I chose the Requires.jl version. The setup (with the extension living in ext/UnPackExt.jl) is compatible with the new "Extension-standard" and requires minimal updates, once this feature is stable. (I had some issues getting the Julia 1.9-beta to work with my VsCode, which is why I did it this way...)

In summary the PR implements:

codecov[bot] commented 1 year ago

Codecov Report

Base: 83.50% // Head: 83.55% // Increases project coverage by +0.04% :tada:

Coverage data is based on head (4ba47c8) compared to base (06058ef). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #455 +/- ## ========================================== + Coverage 83.50% 83.55% +0.04% ========================================== Files 30 31 +1 Lines 4135 4141 +6 ========================================== + Hits 3453 3460 +7 + Misses 682 681 -1 ``` | [Impacted Files](https://codecov.io/gh/JuliaIO/JLD2.jl/pull/455?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaIO) | Coverage Δ | | |---|---|---| | [ext/UnPackExt.jl](https://codecov.io/gh/JuliaIO/JLD2.jl/pull/455?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaIO#diff-ZXh0L1VuUGFja0V4dC5qbA==) | `100.00% <100.00%> (ø)` | | | [src/JLD2.jl](https://codecov.io/gh/JuliaIO/JLD2.jl/pull/455?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaIO#diff-c3JjL0pMRDIuamw=) | `90.29% <100.00%> (+0.58%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaIO). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaIO)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

lukasgrunwald commented 1 year ago

Bump (the failed nightly runs are not due to any changes made in this commit)