Skip to content

Commit

Permalink
Update trace
Browse files Browse the repository at this point in the history
  • Loading branch information
paschermayr committed Jul 29, 2022
1 parent 67c9c3c commit b68bfe8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Baytes"
uuid = "72ddfcfc-6e9d-43df-829b-7aed7c549d4f"
authors = ["Patrick Aschermayr <p.aschermayr@gmail.com>"]
version = "0.1.10"
version = "0.1.11"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand Down
3 changes: 2 additions & 1 deletion src/sampling/chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function chainsummary(
@unpack progress = trace.info
@unpack tagged, paramnames = transform
Nparams = length(tagged)
Nchains = length(transform.chains)
## Flatten parameter to 3D array
computingtime = progress.enabled ? (progress.tlast - progress.tinit) : NaN
arr3D = trace_to_3DArray(trace, transform)
Expand All @@ -162,7 +163,7 @@ function chainsummary(
end
## Compute summary statistics
#!NOTE If more than 1 chain used, can use cross-chain diagnostics
if trace.info.sampling.Nchains > 1
if Nchains > 1
#NOTE: Most of the computing time of the function happens here
chainparamdiagnostic = chainparamdiagnostics(arr3D, computingtime)
else
Expand Down
8 changes: 6 additions & 2 deletions src/sampling/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ function trace_to_3DArray(
## Preallocate array
mcmcchain = zeros(length(effective_iterations), length(tagged), length(chains))
## Flatten corresponding parameter
Threads.@threads for (idx, chain) in collect(enumerate(chains))
#!NOTE: This is threadsave, but chain is not flattened in correct ordered, which might be troublesome for MCMC chain analysis.
# Threads.@threads for (idx, chain) in collect(enumerate(chains))
for (idx, chain) in collect(enumerate(chains))
for (iter0, iterburnin) in enumerate(effective_iterations)
mcmcchain[iter0, :, idx] .= flatten(tagged.info.reconstruct, subset(trace.val[chain][iterburnin], tagged.parameter))
end
Expand Down Expand Up @@ -230,7 +232,9 @@ function flatten_chainvals(
## Preallocate array
mcmcchain = [ [ zeros(tagged.info.reconstruct.default.output, length(tagged)) for _ in eachindex(effective_iterations) ] for _ in eachindex(chains) ]
## Flatten corresponding parameter
Threads.@threads for (idx, chain) in collect(enumerate(chains))
#!NOTE: This is threadsave, but chain is not flattened in correct ordered, which might be troublesome for MCMC chain analysis.
# Threads.@threads for (idx, chain) in collect(enumerate(chains))
for (idx, chain) in collect(enumerate(chains))
for (iter0, iterburnin) in enumerate(effective_iterations)
mcmcchain[idx][iter0] .= flatten(tagged.info.reconstruct, subset(trace.val[chain][iterburnin], tagged.parameter))
end
Expand Down

2 comments on commit b68bfe8

@paschermayr
Copy link
Owner Author

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

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

Please sign in to comment.