Skip to content

Issue a better error for vector of missings / partial missings #969

@penelopeysm

Description

@penelopeysm
julia> using DynamicPPL, Distributions, LinearAlgebra

julia> @model function f()
           m ~ Normal()
           x ~ MvNormal(fill(m, 2), I)
           return (; x=x)
       end
f (generic function with 2 methods)

julia> (f() | (;x = missing))()
(x = [-0.6057165705360297, -1.9535499079746597],)

julia> (f() | (;x = [missing, missing]))()
ERROR: MethodError: no method matching loglikelihood(::IsoNormal, ::Vector{Missing})
The function `loglikelihood` exists, but no method is defined for this combination of argument types.

julia> (f() | (;x = [1.0, missing]))()
ERROR: MethodError: no method matching loglikelihood(::IsoNormal, ::Vector{Union{Missing, Float64}})
The function `loglikelihood` exists, but no method is defined for this combination of argument types.

The latter two cases crop up every now and then, and we have to tell people that (1) the correct way is to only put one missing, or (2) you can't condition on part of a variable (not since .~ was simplified #804). I think it should be reasonably easy to make a more useful error message somewhere in DynamicPPL (either in getconditioned or getfixed, or possibly in tilde_observe!! / observe itself), and/or insert a warning in check_model.

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