Giter Club home page Giter Club logo

Comments (6)

jrevels avatar jrevels commented on June 10, 2024 1

I think I'm running into this as well. Here's my reduced case (on master of JLD.jl):

julia> immutable Foo
           t::Tuple{Float64, Float64}
       end

julia> immutable Bar
           f::Foo
       end

julia> using JLD

julia> JLD.save("test.jld", "bar", Bar(Foo((1.0, 1.0))))

julia> JLD.load("test.jld")
ERROR: stored type Foo does not match currently loaded type
 in jldatatype at /Users/jarrettrevels/.julia/v0.4/JLD/src/jld_types.jl:689
 in jldatatype at /Users/jarrettrevels/.julia/v0.4/JLD/src/jld_types.jl:679
 in read at /Users/jarrettrevels/.julia/v0.4/JLD/src/JLD.jl:370
 in read at /Users/jarrettrevels/.julia/v0.4/JLD/src/JLD.jl:346
 in anonymous at /Users/jarrettrevels/.julia/v0.4/JLD/src/JLD.jl:1185
 in jldopen at /Users/jarrettrevels/.julia/v0.4/JLD/src/JLD.jl:245
 in load at /Users/jarrettrevels/.julia/v0.4/JLD/src/JLD.jl:1184
 in load at /Users/jarrettrevels/.julia/v0.4/FileIO/src/loadsave.jl:42

This only seems to occur when the Tuple is nested within the field of another type. For example, these all work without error:

julia> JLD.save("test.jld", "foo", Foo((1.0, 1.0)))

julia> JLD.load("test.jld")
Dict{ByteString,Any} with 1 entry:
  "foo" => Foo((1.0,1.0))

julia> JLD.save("test.jld", "foo", [Foo((1.0, 1.0))])

julia> JLD.load("test.jld")
Dict{ByteString,Any} with 1 entry:
  "foo" => [Foo((1.0,1.0))]

julia> JLD.save("test.jld", "foo", Dict("f" => Foo((1.0, 1.0))))

julia> JLD.load("test.jld")
Dict{ByteString,Any} with 1 entry:
  "foo" => Dict("f"=>Foo((1.0,1.0)))

Since I'm running from this package's master branch, INLINE_TUPLE = false. I tried switching it to true just to see what would happen, and I got ERROR: Error dereferencing object when calling JLD.load("test.jld").

from jld.jl.

pagnani avatar pagnani commented on June 10, 2024

I probably have the same problem

type T2
           h::Vector{Tuple{Int,Int}}
end

x = T2([(1,2),(2,3)])
@save "x.jld" x
@load "x.jld"
ERROR: MethodError: `jlconvert!` has no method matching jlconvert!(::Ptr{Tuple{Int64,Int64}}, ::Type{Tuple{Int64,Int64}}, ::JLD.JldFile, ::Ptr{UInt8})
Closest candidates are:
  jlconvert!(::Ptr{T}, ::Union{Type{Float32},Type{Float64},Type{Int16},Type{Int32},Type{Int64},Type{Int8},Type{UInt16},Type{UInt32},Type{UInt64},Type{UInt8}}, ::JLD.JldFile, ::Ptr{T})
  jlconvert!(::Ptr{T}, ::Type{Void}, ::JLD.JldFile, ::Ptr{T})
 in read_vals at /Users/pagnani/.julia/v0.4/JLD/src/JLD.jl:397
 in read_array at /Users/pagnani/.julia/v0.4/JLD/src/JLD.jl:359
 in read at /Users/pagnani/.julia/v0.4/JLD/src/JLD.jl:322
 in read_ref at /Users/pagnani/.julia/v0.4/JLD/src/JLD.jl:448
 [inlined code] from /Users/pagnani/.julia/v0.4/JLD/src/jld_types.jl:428
 in jlconvert at /Users/pagnani/.julia/v0.4/JLD/src/jld_types.jl:436
 in read_scalar at /Users/pagnani/.julia/v0.4/JLD/src/JLD.jl:348
 in read at /Users/pagnani/.julia/v0.4/JLD/src/JLD.jl:320
 in read at /Users/pagnani/.julia/v0.4/JLD/src/JLD.jl:305
 in anonymous at no file

The very same problem occurs with a

Type T1
      h::Dict{Tuple{Int,Int}, Float64}
end

Is this a known limitation of JLD?

from jld.jl.

simonster avatar simonster commented on June 10, 2024

@pagnani Did you set INLINE_TUPLE = true? Does this happen without that change?

from jld.jl.

pagnani avatar pagnani commented on June 10, 2024

Well the first lines of jld_types.jl are

# Controls whether tuples and non-pointerfree immutables, which Julia
# stores as references, are stored inline in compound types when
# possible. Currently this is problematic because Julia fields of these
# types may be undefined.
const INLINE_TUPLE = true

from jld.jl.

timholy avatar timholy commented on June 10, 2024

In the short term, you all might be able to work around this using a custom serializer.

from jld.jl.

KristofferC avatar KristofferC commented on June 10, 2024

Also hitting this. For me, it seems to have to do with what module the type is defined in:

using StaticArrays
using JLD

s = rand(SVector{3});
save("jl.jld", "s", s); 
load("jl.jld") # This works!

module M
   using StaticArrays
   immutable Typ{N,T}
       v::SVector{N,T}
   end
end

s2 = M.Typ(rand(SVector{3}));
save("jl2.jld", "s2", s2)
load("jl2.jld") # Crashes!

from jld.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.