You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for answering #627. So far it works well, however I found an issue:
using JLD2
struct Foo
x::Intendjldsave("test.jld2"; type=Foo)
load("test.jld2", "type"; typemap=Dict("Main.Foo"=>JLD2.Upgrade(Foo)))
This should reasonably yield Foo, but it yields Upgrade(Foo). To put it another way, if I'm deserializing a Dict(Foo=>4), it'll become Dict(Upgrade(Foo)=>4).
The text was updated successfully, but these errors were encountered:
that makes sense, given how things are implemented....
Things should work if you "just" do: load("test.jld2", "type"; typemap=Dict("Main.Foo"=>Foo))
(Which then does not allow you to deserialize instances of the changed Foo in the same operation)...
I don't think there is an easy fix right now.
To improve things, we would have to add an extra information passage pathway into JLD2. jlconvert loads a type and returns JLD2.Upgrade(Foo) in your case.
This is important for reconstructing instances, as it signals to the calling function that the rconvert constructor should be used instead of the default version.
However, this is somewhat inconsistent as jlconvert normally promises to return the requested type.
EDIT: also for reference
julia> jldsave("test.jld2"; type=DataType[Float64, Foo])
julia> load("test.jld2"; typemap=Dict("Main.Foo"=>JLD2.Upgrade(Foo)))
Error encountered while load FileIO.File{FileIO.DataFormat{:JLD2}, String}("test.jld2").
Fatal error:
ERROR: MethodError: Cannot `convert` an object of type JLD2.Upgrade to an object of type DataType
Closest candidates are:
convert(::Type{T}, ::T) where T
@ Base Base.jl:84
Stacktrace:
[1] setindex!(A::Vector{DataType}, x::JLD2.Upgrade, i1::Int64)
@ Base ./array.jl:1021
[2] macro expansion
@ /data.lmp/isensee/.julia/dev/JLD2/src/io/dataio.jl:125 [inlined]
[3] macro expansion
@ ./simdloop.jl:77 [inlined]
[4] read_array!(v::Vector{…}, f::JLD2.JLDFile{…}, rr::JLD2.MappedRepr{…})
@ JLD2 /data.lmp/isensee/.julia/dev/JLD2/src/io/dataio.jl:122
Thank you for answering #627. So far it works well, however I found an issue:
This should reasonably yield
Foo
, but it yieldsUpgrade(Foo)
. To put it another way, if I'm deserializing aDict(Foo=>4)
, it'll becomeDict(Upgrade(Foo)=>4)
.The text was updated successfully, but these errors were encountered: