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
I have an issue where I'd like to change a type in my package but have JLD2 files with data saved.
I'd like to easily load this data and then map it to the new type.
The solution that comes to mind is that I can preserve the old type as something like:
struct MyType
i::Int
j::Int
end
struct OldMyType
i::Int
end
data = load("mydata.jl", "MyType" => :OldMyType)
# work to convert from old type to the new type
Maybe there's a way to make this work (it is looking to use convert which seems tantilizing as a way to plug in the correct function) but I seem to not be implementing it right. If this is possible, it could be added to the documentation.
The text was updated successfully, but these errors were encountered:
This would indeed be nice.
A workaround might be to introduce an intermediate step.
in one julia session you define
struct MyType
i::Int
end
struct MyNewType
i::Int
j::Int
end
data = load("mydata.jld2")
#convert types
save("intermediate.jld2", data)
and in the next julia session you define
struct MyType
i::Int
j::Int
end
struct MyNewType
i::Int
j::Int
end
data = load("mydata.jld2")
#trivial conversion from MyNewType to MyType
save("updated.jld2", data)
I have an issue where I'd like to change a type in my package but have JLD2 files with data saved.
I'd like to easily load this data and then map it to the new type.
The solution that comes to mind is that I can preserve the old type as something like:
Maybe there's a way to make this work (it is looking to use
convert
which seems tantilizing as a way to plug in the correct function) but I seem to not be implementing it right. If this is possible, it could be added to the documentation.The text was updated successfully, but these errors were encountered: