Skip to content

Commit

Permalink
Patch un-imported Accessors in MCMCChainsExt (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxd3 authored Nov 18, 2024
1 parent 26ef662 commit 5dedc30
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
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.7.0"
version = "0.7.1"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down
1 change: 1 addition & 0 deletions ext/JuliaBUGSMCMCChainsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using JuliaBUGS.AbstractPPL
using JuliaBUGS.BUGSPrimitives
using JuliaBUGS.LogDensityProblems
using JuliaBUGS.LogDensityProblemsAD
using JuliaBUGS: Accessors
using AbstractMCMC
using MCMCChains: Chains

Expand Down
32 changes: 32 additions & 0 deletions test/ext/mcmchains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,36 @@
@test means[:beta].nt.mean[1] 2.1 atol = 0.2
@test means[:sigma].nt.mean[1] 0.9 atol = 0.2
@test means[:gen_quant].nt.mean[1] 4.2 atol = 0.2

# test for more complicated varnames
model_def = @bugs begin
A[1, 1:3] ~ Dirichlet(ones(3))
A[2, 1:3] ~ Dirichlet(ones(3))
A[3, 1:3] ~ Dirichlet(ones(3))

mu[1:3] ~ MvNormal(zeros(3), 10 * Diagonal(ones(3)))
sigma[1] ~ InverseGamma(2, 3)
sigma[2] ~ InverseGamma(2, 3)
sigma[3] ~ InverseGamma(2, 3)
end
model = compile(model_def, (;))
ad_model = ADgradient(:ReverseDiff, model; compile=Val(true))
hmc_chain = AbstractMCMC.sample(ad_model, NUTS(0.8), 10; chain_type=Chains)
@test hmc_chain.name_map[:parameters] == [
Symbol("sigma[3]"),
Symbol("sigma[2]"),
Symbol("sigma[1]"),
Symbol("mu[1:3][1]"),
Symbol("mu[1:3][2]"),
Symbol("mu[1:3][3]"),
Symbol("A[3, 1:3][1]"),
Symbol("A[3, 1:3][2]"),
Symbol("A[3, 1:3][3]"),
Symbol("A[2, 1:3][1]"),
Symbol("A[2, 1:3][2]"),
Symbol("A[2, 1:3][3]"),
Symbol("A[1, 1:3][1]"),
Symbol("A[1, 1:3][2]"),
Symbol("A[1, 1:3][3]"),
]
end

2 comments on commit 5dedc30

@sunxd3
Copy link
Member Author

@sunxd3 sunxd3 commented on 5dedc30 Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

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/119700

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.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

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:

git tag -a v0.7.1 -m "<description of version>" 5dedc3026b80bc0e09332f504912d8cc1245e40f
git push origin v0.7.1

Please sign in to comment.