TuringLang / DynamicPPL.jl

Implementation of domain-specific language (DSL) for dynamic probabilistic programming
https://turinglang.org/DynamicPPL.jl/
MIT License
164 stars 29 forks source link

`BangBang.setindex!!(vi::SimpleVarInfo{<:AbstractDict}, val, vn::VarName)` returns eltype Any arrays when `vn` is multidimensional #530

Closed sunxd3 closed 6 months ago

sunxd3 commented 1 year ago

MWE

julia> using DynamicPPL
[ Info: Precompiling DynamicPPL [366bfd00-2699-11ea-058f-f148b4cae6d8]

julia> svi = SimpleVarInfo(Dict(@varname(a)=>zeros(2, 2)))
SimpleVarInfo(Dict(a => [0.0 0.0; 0.0 0.0]), 0.0)

julia> DynamicPPL.setindex!!(svi, ones(2, 2), @varname(a[1:2, 1:2]))
SimpleVarInfo(Dict{VarName{:a, Setfield.IdentityLens}, Matrix{Any}}(a => [1.0 1.0; 1.0 1.0]), 0.0)

Possible solutions:

torfjelde commented 1 year ago

More similar issues: https://github.com/TuringLang/Turing.jl/discussions/2094#discussioncomment-7212953