Hello, I have the following problem:
I try to save a random number generator to a jld2 file and load it later.
Here is an example:
using Random
using FileIO
using JLD2
rng = Random.MersenneTwister(1)
jldopen("test_rng.jld2", true, true, true, IOStream) do file
file["rng"] = rng
end
rng_load = load("test_rng.jld2", "rng")
@show typeof(rng)
@show typeof(rng_load)
The output is:
┌ Warning: type DSFMT.DSFMT.DSFMT_state does not exist in workspace; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/xpVxm/src/data.jl:1153
┌ Warning: saved type MersenneTwister has field state::getfield(JLD2.ReconstructedTypes, Symbol("##DSFMT.DSFMT.DSFMT_state#378")), but workspace type has field state::Random.DSFMT.DSFMT_state, and no applicable convert method exists; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/xpVxm/src/data.jl:420
typeof(rng) = MersenneTwister
typeof(rng_load) = getfield(JLD2.ReconstructedTypes, Symbol("##MersenneTwister#379"))
So obviosly this does not work. I would like to know why and ho to correct this.
Remark: I use this jldopen
version for saving because the real code runs on a cluster and there where issues with the saving with @save
macro.
Here I have a link to an issue I have opend for JLD2: Load MersenneTwister fails · Issue #112 · JuliaIO/JLD2.jl · GitHub