Skip to content

Commit

Permalink
Explicitly convert the type of values before create a Chain (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxd3 authored Sep 20, 2023
1 parent e4eb9f3 commit bd399c7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
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.2.0"
version = "0.2.1"

[deps]
AbstractPPL = "7a57a42e-76ec-4ea3-a279-07e840d6d9cf"
Expand Down
17 changes: 10 additions & 7 deletions ext/JuliaBUGSAdvancedHMCExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function AbstractMCMC.bundle_samples(
generated_quantities = []
for i in eachindex(ts)
vi = first(evaluate!!(model, LogDensityContext(), samples[i]))
push!(param_vals, vi[param_vars])
push!(generated_quantities, vi[generated_vars])
push!(param_vals, [vi[param_var] for param_var in param_vars])
push!(generated_quantities, [vi[generated_var] for generated_var in generated_vars])
end

param_name_leaves = vcat(
Expand All @@ -61,11 +61,14 @@ function AbstractMCMC.bundle_samples(
flattened_param_vals = [vcat(p...) for p in param_vals]
flattened_generated_quantities = [vcat(gq...) for gq in generated_quantities]
vals = [
vcat(
flattened_param_vals[i],
flattened_generated_quantities[i],
ts[i].z.ℓπ.value,
collect(values(AdvancedHMC.stat(ts[i]))),
convert(
Vector{Real},
vcat(
flattened_param_vals[i],
flattened_generated_quantities[i],
ts[i].z.ℓπ.value,
collect(values(AdvancedHMC.stat(ts[i]))),
),
) for i in eachindex(ts)
]

Expand Down
19 changes: 19 additions & 0 deletions src/graphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ struct ConcreteNodeInfo <: NodeInfo
node_args::Vector
end

function Base.show(io::IO, n::ConcreteNodeInfo)
if n isa ConcreteNodeInfo
print(
io,
"ConcreteNodeInfo(\n",
"\tNode Type: ",
n.node_type,
"\n",
"\tNode Function Expression: ",
n.node_function_expr,
"\n",
"\tNode Arguments: ",
n.node_args,
"\n",
")",
)
end
end

function ConcreteNodeInfo(var::Var, vars, node_functions, node_args)
return ConcreteNodeInfo(
vars[var],
Expand Down

2 comments on commit bd399c7

@sunxd3
Copy link
Member Author

@sunxd3 sunxd3 commented on bd399c7 Sep 20, 2023

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

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.2.1 -m "<description of version>" bd399c7775d2d22b68e4b03fe1bedbc907c25df2
git push origin v0.2.1

Please sign in to comment.