Skip to content

fix: repair duplicate form-constraint @warn (UndefVarError opt) - #314

Open
docxology wants to merge 1 commit into
ReactiveBayes:mainfrom
docxology:fix/constraint-warn-undefvar
Open

fix: repair duplicate form-constraint @warn (UndefVarError opt)#314
docxology wants to merge 1 commit into
ReactiveBayes:mainfrom
docxology:fix/constraint-warn-undefvar

Conversation

@docxology

Copy link
Copy Markdown

Description

Fixes #2. In src/plugins/variational_constraints/variational_constraints_engine.jl, the
"node already has a functional form constraint" warning (@warn lazy"...") interpolated
undefined local variables opt and constraint_data, raising UndefVarError: opt instead
of producing the intended warning. Affects both the MarginalFormConstraint (line 954) and
MessageFormConstraint (line 969) paths.

Change

Replace the broken interpolations with bound values:

-        @warn lazy"Node $node already has functional form constraint $(opt[:q]) applied, therefore $constraint_data will not be applied"
+        @warn "Node $node already has functional form constraint $(getconstraint(marginal_constraint)) applied, therefore it will not be applied"

and for the message path (line 969) the analogous fix using getconstraint(message_constraint).

Tests

Added a regression test that pre-sets VariationalConstraintsMarginalFormConstraintKey (and
VariationalConstraintsMessagesFormConstraintKey) on a node, applies a second form
constraint, and asserts (a) a warning is emitted and (b) the original constraint is preserved.

Verification

  • test/plugins/variational_constraints/variational_constraints_engine_tests.jl: pass
  • test/plugins/variational_constraints/variational_constraints_tests.jl: pass

Closes #305

The 'already has functional form constraint' warnings referenced undefined
locals opt and constraint_data inside lazy"...", producing UndefVarError
instead of the intended informative warning. Use bound getconstraint(...).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@warn in apply_constraints! throws UndefVarError: opt when a node already has a form constraint

1 participant