Advanced typemap and full user control#650
Merged
JonasIsensee merged 4 commits intomasterfrom Jun 26, 2025
Merged
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #650 +/- ##
==========================================
- Coverage 85.36% 85.33% -0.04%
==========================================
Files 37 37
Lines 4407 4404 -3
==========================================
- Hits 3762 3758 -4
- Misses 645 646 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR gives the user full control over type reconstruction.
Simply pass a function
(f::JLDFile, typepath::String, params::Vector) -> typeas keyword toloadorjldopen.This function is then called for every single type that will be decoded.
The default implementation is
JLD2.default_typemapand all standard cases can simply be forwarded to it.Example:
Here, for bogus reasons we want to load a
Complex{Int}as aComplex{Float64}while also modifying the real part during loading.if typepath == "Base.Complex" && params == [Int]checks that onlyComplex{Int}get changed andwrapping the updated type in
JLD2.Upgradeensures that our custom implementation ofJLD2.rconvertgets called during loading.closes #630