You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have played with the updated BSON after #29 and I still seem to get unexpected behavior:
Changed type of nested dictionaries on reload
julia> inner_d =Dict(:v=>0)
Dict{Symbol,Int64} with 1 entry::v=>0
julia> outer_d =Dict(:d=>inner_d)
Dict{Symbol,Dict{Symbol,Int64}} with 1 entry::d=>Dict(:v=>0)
julia>save("test.bson", outer_d)
julia>load("test.bson")
BSON.BSONDict with 1 entry::d=> BSON.BSONDict(:v=>0)
According to README, i would expect both the inner and outer dictionaries to be of the Dict type when loaded.
Lost array type on reload
julia> v = [zeros(1) for i in1:2]
2-element Array{Array{Float64,1},1}:
[0.0]
[0.0]
julia> D =Dict(:d=>v)
Dict{Symbol,Array{Array{Float64,1},1}} with 1 entry::d=> [[0.0], [0.0]]
julia>save("test_v.bson", D)
julia>load("test_v.bson")
BSON.BSONDict with 1 entry::d=> Any[[0.0], [0.0]]
Here, I would expect the loaded dictionary to be Dict, not BSONDict and the array elements to be of type Array{Float64,1}, not Any.
Quickly looking through the issues, such effects of save and load could imo be the cause of some of the reports (#76, #75).
I think it would be worthwhile to mention this behaviour in the README to save people headaches with unexpected errors.
PS: I was having similar issues even before the merge of #29, the change in #29 at least made these issues much easier to track.
The text was updated successfully, but these errors were encountered:
BoZenKhaa
changed the title
save and load modify saved structures
save and load unexpectedly modify types of values
Feb 19, 2021
BoZenKhaa
added a commit
to BoZenKhaa/BSON.jl
that referenced
this issue
Feb 19, 2021
There are ongoing issues with BSON changing types of saved structures JuliaIO#84 that may lead to cryptic error messages. It would be nice to have a warning in the README before this behaviour addressed in some way.
I have played with the updated BSON after #29 and I still seem to get unexpected behavior:
According to README, i would expect both the inner and outer dictionaries to be of the
Dict
type when loaded.Here, I would expect the loaded dictionary to be
Dict
, notBSONDict
and the array elements to be of typeArray{Float64,1}
, notAny
.Quickly looking through the issues, such effects of save and load could imo be the cause of some of the reports (#76, #75).
I think it would be worthwhile to mention this behaviour in the README to save people headaches with unexpected errors.
PS: I was having similar issues even before the merge of #29, the change in #29 at least made these issues much easier to track.
The text was updated successfully, but these errors were encountered: