Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oxinabox/95f71548345e8fc583da to your computer and use it in GitHub Desktop.
Save oxinabox/95f71548345e8fc583da to your computer and use it in GitHub Desktop.
JLD_breaking_with_multiple_complex_writes
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"using HDF5\n",
"using JLD"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Dict{ByteString,Any} with 2 entries:\n",
" \"otherweights\" => 16\n",
" \"weights\" => 15"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Works fine\n",
"jldopen(\"example.jld\", \"w\") do fh\n",
" write(fh, \"weights\", 15)\n",
"end\n",
"jldopen(\"example.jld\", \"r+\") do fh\n",
" write(fh, \"otherweights\", 16)\n",
"\n",
"end\n",
"load(\"example.jld\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Dict{ByteString,Any} with 2 entries:\n",
" \"otherweights\" => [:VeryHeavy,:VeryLight]\n",
" \"weights\" => [:Heavy,:Light]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Also works\n",
"jldopen(\"example.jld\", \"w\") do fh\n",
" write(fh, \"weights\", [:Heavy, :Light])\n",
"end\n",
"jldopen(\"example.jld\", \"r+\") do fh\n",
" write(fh, \"otherweights\", [:VeryHeavy, :VeryLight])\n",
"\n",
"end\n",
"load(\"example.jld\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Dict{ByteString,Any} with 2 entries:\n",
" \"otherweights\" => [(:VeryHeavy,200),(:VeryLight,25)]\n",
" \"weights\" => [(:Heavy,100),(:Light,50)]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Works\n",
"jldopen(\"example.jld\", \"w\") do fh\n",
" write(fh, \"weights\", [(:Heavy,100), (:Light,50)])\n",
" write(fh, \"otherweights\", [(:VeryHeavy, 200), (:VeryLight, 25)])\n",
"end\n",
"load(\"example.jld\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "LoadError",
"evalue": "LoadError: stored type Core.Tuple{Core.Symbol,Core.Int64} does not match currently loaded type\nwhile loading In[5], in expression starting on line 9",
"output_type": "error",
"traceback": [
"LoadError: stored type Core.Tuple{Core.Symbol,Core.Int64} does not match currently loaded type\nwhile loading In[5], in expression starting on line 9",
"",
" in jldatatype at /home/ubuntu/.julia/v0.5/JLD/src/jld_types.jl:689",
" in read at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:370",
" in read_ref at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:498",
" in read_refs at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:471",
" in read_array at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:407",
" in read at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:372",
" in read at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:346",
" in anonymous at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:1185",
" in jldopen at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:245",
" [inlined code] from /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:243",
" in load at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:1184",
" in load at /home/ubuntu/.julia/v0.5/FileIO/src/loadsave.jl:42",
" [inlined code] from essentials.jl:114"
]
}
],
"source": [
"#Does Not work\n",
"jldopen(\"example.jld\", \"w\") do fh\n",
" write(fh, \"weights\", [(:Heavy,100), (:Light,50)])\n",
"end\n",
"jldopen(\"example.jld\", \"r+\") do fh\n",
" write(fh, \"otherweights\", [(:VeryHeavy, 200), (:VeryLight, 25)])\n",
"\n",
"end\n",
"load(\"example.jld\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "LoadError",
"evalue": "LoadError: stored type Core.Tuple{Core.Symbol,Core.Symbol} does not match currently loaded type\nwhile loading In[6], in expression starting on line 9",
"output_type": "error",
"traceback": [
"LoadError: stored type Core.Tuple{Core.Symbol,Core.Symbol} does not match currently loaded type\nwhile loading In[6], in expression starting on line 9",
"",
" in jldatatype at /home/ubuntu/.julia/v0.5/JLD/src/jld_types.jl:689",
" in read at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:370",
" in read_ref at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:498",
" in read_refs at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:471",
" in read_array at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:407",
" in read at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:372",
" in read at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:346",
" in anonymous at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:1185",
" in jldopen at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:245",
" [inlined code] from /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:243",
" in load at /home/ubuntu/.julia/v0.5/JLD/src/JLD.jl:1184",
" in load at /home/ubuntu/.julia/v0.5/FileIO/src/loadsave.jl:42",
" [inlined code] from essentials.jl:114"
]
}
],
"source": [
"#Does Not work\n",
"jldopen(\"example.jld\", \"w\") do fh\n",
" write(fh, \"weights\", [(:Heavy,:Heavy), (:Light,:Heavy)])\n",
"end\n",
"jldopen(\"example.jld\", \"r+\") do fh\n",
" write(fh, \"otherweights\", [(:VeryHeavy, :Heavy), (:VeryLight, :Heavy)])\n",
"\n",
"end\n",
"load(\"example.jld\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.5.0-dev",
"language": "julia",
"name": "julia-0.5"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.5.0"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment