Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load Measurement quantities with JLD.jl #58

Closed
MasonProtter opened this issue Dec 19, 2019 · 3 comments
Closed

Can't load Measurement quantities with JLD.jl #58

MasonProtter opened this issue Dec 19, 2019 · 3 comments

Comments

@MasonProtter
Copy link

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
Copy link
Member

giordano commented Dec 19, 2019

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
Copy link
Member

Note that now Measurement objects can be serialised with JLD2: JuliaIO/JLD2.jl#189

@MasonProtter
Copy link
Author

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants