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

Permit dot call (like Distributions.Normal) to be used in model definition #237

Merged
merged 3 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "JuliaBUGS"
uuid = "ba9fb4c0-828e-4473-b6a1-cd2560fee5bf"
version = "0.6.5"
version = "0.7.0"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down
2 changes: 2 additions & 0 deletions src/parser/bugs_macro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ function bugs_expression(expr, line_num)
error(
"Keyword argument syntax is not supported in BUGS, error at $line_num: $(expr)"
)
elseif Meta.isexpr(expr, :.)
return expr
else
error("Invalid expression at $line_num: `$expr`")
end
Expand Down
8 changes: 8 additions & 0 deletions test/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,11 @@ end
@test AbstractPPL.get(model_init_1.evaluation_env, @varname(beta)) == 1
end
end

@testset "dot call" begin
model_def = @bugs begin
x[1:2] ~ Distributions.product_distribution(fill(Distributions.Normal(0, 1), 2))
end
model = compile(model_def, (;))
@test model.evaluation_env.x isa Vector{Float64}
end
Loading