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
By a coincidence I stumbled upon a possible bug in Dict.
See MWE below:
A test function that copies keys and values from one dict to another:
function foo(e::T,c::S) where {S,T}
mydict1 = Dict{String,T}()
mydict1["a"] = zero(T)
mydict1["b"] = one(T)
mydict2 = Dict{String,Array{T,1}}()
N = 3
a = zeros(S,N)
for (key,value) in mydict1
for i in 1:N
a[i] = value
end
mydict2[key] = a
end
return mydict2
end
If T==S then the output is wrong:
julia> foo(1.,1.)
Dict{String,Array{Float64,1}} with 2 entries:
"b" => [0.0, 0.0, 0.0]
"a" => [0.0, 0.0, 0.0]
Or
julia> foo(1,1)
Dict{String,Array{Float64,1}} with 2 entries:
"b" => [0, 0, 0]
"a" => [0, 0, 0]
But if T != S then I get the correct output:
julia> foo(1,1.)
Dict{String,Array{Int64,1}} with 2 entries:
"b" => [1, 1, 1]
"a" => [0, 0, 0]
julia> foo(1.,1)
Dict{String,Array{Float64,1}} with 2 entries:
"b" => [1.0, 1.0, 1.0]
"a" => [0.0, 0.0, 0.0]
Tried to track it down further but could not find the source. Am I doing something silly here or is it a bug?
Can try to look more into if I can get some guidance :)
Hi there,
By a coincidence I stumbled upon a possible bug in Dict.
See MWE below:
A test function that copies keys and values from one dict to another:
If T==S then the output is wrong:
Or
But if T != S then I get the correct output:
Tried to track it down further but could not find the source. Am I doing something silly here or is it a bug?
Can try to look more into if I can get some guidance :)
Best, Oliver
The text was updated successfully, but these errors were encountered: