Skip to content

vi[:] unnecessarily casts #1001

@penelopeysm

Description

@penelopeysm
julia> using DynamicPPL, Distributions

julia> @model function g()
           x ~ Poisson(3.5)
           y ~ Normal()
       end;

julia> v = VarInfo(g());

julia> DynamicPPL.getindex_internal(v, @varname(x))
1-element Vector{Int64}:
 1

julia> v[:]
2-element Vector{Float64}:
  1.0
 -0.7525359545725246

This is was causing upstream test failures in Turing because DynamicPPL.unflatten(v, v[:]) can set float values where ints should be present. I worked around it for now by avoiding round-trip unflatten, but this still seems like something that should be fixed here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions