Skip to content

Commit

Permalink
fix warning for predicted datavars
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdmitri committed Sep 18, 2023
1 parent 0c94a12 commit ad7b165
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/constraints/specifications/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ function activate!(constraints::ConstraintsSpecification, nodes::FactorNodesColl
foreach(constraints.factorisation) do spec
specnames = getnames(spec)
foreach(specnames) do specname
if warn && (hasdatavar(variables, specname) || hasconstvar(variables, specname))
if hasdatavar(variables, specname) && allows_missings(variables[specname])

Check warning on line 107 in src/constraints/specifications/constraints.jl

View check run for this annotation

Codecov / codecov/patch

src/constraints/specifications/constraints.jl#L107

Added line #L107 was not covered by tests
# skip, because it is fine to have a datavar in the factorization constraint, which allows missings
nothing
elseif warn && (hasdatavar(variables, specname) || hasconstvar(variables, specname))

Check warning on line 110 in src/constraints/specifications/constraints.jl

View check run for this annotation

Codecov / codecov/patch

src/constraints/specifications/constraints.jl#L109-L110

Added lines #L109 - L110 were not covered by tests
@warn "Constraints specification has factorisation constraint for `q($(join(specnames, ", ")))`, but `$(specname)` is not a random variable. Data variables and constants in the model are forced to be factorized by default such that `q($(join(specnames, ", "))) = q($(specname))q(...)` . Use `warn = false` option during constraints specification to suppress this warning."
elseif warn && !hasrandomvar(variables, specname)
@warn "Constraints specification has factorisation constraint for `q($(join(specnames, ", ")))`, but variables collection has no random variable named `$(specname)`. Use `warn = false` option during constraints specification to suppress this warning."
Expand Down

0 comments on commit ad7b165

Please sign in to comment.