Can't load Measurement quantities with JLD.jl
MasonProtter opened this issue · 3 comments
MasonProtter commented
Here's a MWE:
julia> using Measurements, JLD
julia> x = 1 ± 0.1
1.0 ± 0.1
julia> @save "x.jld" x
julia> exit()
~$ julia
julia> using Measurements, JLD
julia> @load "x.jld" x
ERROR: MethodError: no method matching setindex!(::Measurements.Derivatives{Float64}, ::Float64, ::Tuple{Float64,Float64,UInt64})
Closest candidates are:
setindex!(::AbstractDict, ::Any, ::Any, ::Any, ::Any...) at abstractdict.jl:477
Stacktrace:
[1] convert(::Type{Measurements.Derivatives{Float64}}, ::JLD.AssociativeWrapper{Tuple{Float64,Float64,UInt64},Float64,Measurements.Derivatives{Float64}}) at /Users/mason/.julia/packages/JLD/1BoSz/src/JLD.jl:809
[2] readas(::JLD.AssociativeWrapper{Tuple{Float64,Float64,UInt64},Float64,Measurements.Derivatives{Float64}}) at /Users/mason/.julia/packages/JLD/1BoSz/src/JLD.jl:792
[3] read_scalar(::JLD.JldDataset, ::HDF5.HDF5Datatype, ::Type) at /Users/mason/.julia/packages/JLD/1BoSz/src/JLD.jl:398
[4] read(::JLD.JldDataset) at /Users/mason/.julia/packages/JLD/1BoSz/src/JLD.jl:370
[5] read_ref(::JLD.JldFile, ::HDF5.HDF5ReferenceObj) at /Users/mason/.julia/packages/JLD/1BoSz/src/JLD.jl:502
[6] jlconvert(::Type{Measurement{Float64}}, ::JLD.JldFile, ::Ptr{UInt8}) at /Users/mason/.julia/packages/JLD/1BoSz/src/jld_types.jl:434
[7] read_scalar(::JLD.JldDataset, ::HDF5.HDF5Datatype, ::Type) at /Users/mason/.julia/packages/JLD/1BoSz/src/JLD.jl:398
[8] read(::JLD.JldDataset) at /Users/mason/.julia/packages/JLD/1BoSz/src/JLD.jl:370
[9] read(::JLD.JldFile, ::String) at /Users/mason/.julia/packages/JLD/1BoSz/src/JLD.jl:346
[10] top-level scope at /Users/mason/.julia/packages/JLD/1BoSz/src/JLD.jl:1196
giordano commented
Measurements.Derivatives
is an immutable dictionary, so setindex!
doesn't make much sense. Any idea of what would make it possible to make this work? I never played much with JLD.
giordano commented
Note that now Measurement
objects can be serialised with JLD2: JuliaIO/JLD2.jl#189
MasonProtter commented
Nice!