JuliaArrays / JuliaArrays/StaticArrays.jl
Load error of parametric type using StaticArrays from .jld file
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
Hello, I am having issues loading saved custom parametric type using JLD in Julia 1.5.
The following example:
using JLD
using StaticArrays
struct MyType{N}
a::SVector{N, Int64}
end
MyType{2}(SA[1,2])
JLD.save("test.jld", "s", MyType{2}(SA[1,2]))
load("test.jld")
produces this error:
ERROR: stored type MyType{2} does not match currently loaded type
I get the same error if the parameter is the type and not the size.
Everything works fine when using the StaticArray directly:
julia> JLD.save("test.jld", "s", SVector{2, Int64}(1,2))
julia> load("test.jld")
Dict{String,Any} with 1 entry:
"s" => [1, 2]
Similarly, using custom nested parametric types works fine as well:
struct MyType3{T}
a::T
end
struct MyType4{T}
b::MyType3{T}
end
MyType4{Int64}(MyType3{Int64}(1))
JLD.save("test.jld", "s", MyType4{Int64}(MyType3{Int64}(1)))
julia> load("test.jld")
Dict{String,Any} with 1 entry:
"s" => MyType4{Int64}(MyType3{Int64}(1))
What could be causing this? I get this error only with my own parametric types using StaticArrays.
I have posted this also in JLD: https://github.com/JuliaIO/JLD.jl/issues/294
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Julia 1.5 example through JLD.save and load using StaticArrays, comparing the custom MyType{N} case with the working direct SVector and nested-parametric examples. Trace the load-time type mismatch; done means identifying a reproducible cause and documenting or testing the corrected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100