Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand RuleMethodError with list of defined rules for given node #397

Open
wmkouw opened this issue May 1, 2024 · 0 comments · May be fixed by ReactiveBayes/RxInfer.jl#370 or #423
Open

Expand RuleMethodError with list of defined rules for given node #397

wmkouw opened this issue May 1, 2024 · 0 comments · May be fixed by ReactiveBayes/RxInfer.jl#370 or #423
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@wmkouw
Copy link
Member

wmkouw commented May 1, 2024

Currently, when a node is connected to an edge which has a distribution that does not match any of the input argument types for the defined message rules, ReactiveMP will throw a RuleMethodError. For example, the model

@model function test(y)
   r ~ Gamma(1.,1.)
   x ~ Bernoulli(r)
   y ~ Beta(x,1.)
end
infer(model = test(), data = (y = 1.0,))

will throw:

ERROR: RuleMethodError: no method matching rule for the given arguments

Possible fix, define:

@rule Beta(:a, Marginalisation) (q_out::PointMass, q_b::PointMass, ) = begin 
    return ...
end

For new users, this error is difficult to read, interpret and overcome, especially if the user is also new to Julia and is unfamiliar with interpreting stack traces. I propose that we output the list of rules that are defined, for example:

Rules defined for Bernouilli(x|r)
-> r ~ PointMass(..)
-> r ~ Beta(..)

This may help the user specify a model for which inference can be executed successfully.

@bartvanerp already compiled a list in ReactiveMP's documentation: https://reactivebayes.github.io/ReactiveMP.jl/stable/lib/rules/#lib-rules-table. This will save a lot of time; we just need to alter the RuleMethodError code in rule.jl such that it performs a look-up and prints in a user-friendly way.

Suggestions during today's RxInfer meeting mentioned a hierarchical printout. I will look into this.

@wmkouw wmkouw added documentation Improvements or additions to documentation enhancement New feature or request labels May 1, 2024
@wmkouw wmkouw self-assigned this May 1, 2024
@wmkouw wmkouw linked a pull request Oct 15, 2024 that will close this issue
@wmkouw wmkouw linked a pull request Oct 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Status: 📝 In progress
1 participant