Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Permit dot call (like
Distributions.Normal
) to be used in model def…
…inition (#237) The motivation for the PR is initially to allow the use [`product_distribution`](https://juliastats.org/Distributions.jl/stable/multivariate/#Distributions.product_distribution) in JuliaBUGS model. By writing ```julia @bugs begin x[1:2] ~ Distributions.product_distribution(fill(Normal(), 2)) end ``` It also enables ```julia julia> foo(x) = x + 1 foo (generic function with 1 method) julia> model_def = @bugs begin a = Main.foo(b) end quote a = Main.foo(b) end julia> compile(model_def, (;b=2)) BUGSModel (parameters are in transformed (unconstrained) space, with dimension 0): Model parameters: Variable sizes and types: a: type = Int64 b: type = Int64 ``` i.e., an easier way to introduce external functions into JuliaBUGS. This can't fully replace `@register_primitive` yet, because using `Main` module is relying on Julia runtime behavior and not very intuitive. Examples: ```julia julia> module TestModule bar(x) = x + 1 end Main.TestModule julia> model_def = @bugs begin a = TestModule.bar(b) end quote a = TestModule.bar(b) end julia> compile(model_def, (; b = 1)) ERROR: UndefVarError: `TestModule` not defined in `JuliaBUGS` ... ``` one would need to do ```julia julia> model_def = @bugs begin a = Main.TestModule.bar(b) end quote a = Main.TestModule.bar(b) end ``` also ```julia julia> @testset "t" begin foo1(x) = x + 1 model_def = @bugs begin a = Main.foo1(b) end compile(model_def, (; b= 1)) end t: Error During Test at REPL[18]:1 Got exception outside of a @test UndefVarError: `foo1` not defined in `Main` ... ```
- Loading branch information
26ef662
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
26ef662
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/119572
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: