Skip to content

Commit

Permalink
Forward missing arguments to summarystats (#424)
Browse files Browse the repository at this point in the history
* Forward missing arguments to `summarystats`

* Fix test
  • Loading branch information
devmotion authored May 31, 2023
1 parent 90ae875 commit 82def13
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "c7f686f2-ff18-58e9-bc7b-31028e88f75d"
keywords = ["markov chain monte carlo", "probablistic programming"]
license = "MIT"
desc = "Chain types and utility functions for MCMC simulations."
version = "6.0.2"
version = "6.0.3"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down
9 changes: 5 additions & 4 deletions src/stats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ function summarystats(
append_chains::Bool = true,
autocov_method::MCMCDiagnosticTools.AbstractAutocovMethod = AutocovMethod(),
maxlag = 250,
name = "Summary Statistics",
kwargs...
)
# Store everything.
Expand Down Expand Up @@ -339,10 +340,10 @@ function summarystats(
# Summarize.
summary_df = summarize(
_chains, funs...;
func_names = func_names,
append_chains = append_chains,
additional_df = additional_df,
name = "Summary Statistics",
func_names,
append_chains,
additional_df,
name,
sections = nothing
)

Expand Down
4 changes: 2 additions & 2 deletions src/summarize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function Base.convert(::Type{Array}, cs::Array{ChainDataFrame{T},1}) where T<:Na
end

"""
summarize(chains, funs...[; sections, func_names = []])
summarize(chains, funs...[; sections, func_names = [], name = "", append_chains = true])
Summarize `chains` in a `ChainsDataFrame`.
Expand All @@ -143,7 +143,7 @@ function summarize(
)
# If we weren't given any functions, fall back to summary stats.
if isempty(funs)
return summarystats(chains; sections = sections)
return summarystats(chains; sections, append_chains, name)
end

# Generate a chain to work on.
Expand Down
10 changes: 10 additions & 0 deletions test/summarize_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ using Statistics: std
@test parm_df[[:a, :b], :][:,:parameters] == [:a, :b]

all_sections_df = summarize(chns, sections=[:parameters, :internals])
@test all_sections_df isa ChainDataFrame
@test all_sections_df[:,:parameters] == [:a, :b, :c, :d, :e, :f, :g, :h]
@test size(all_sections_df) == (8, 8)
@test all_sections_df.name == ""

all_sections_dfs = summarize(chns, sections=[:parameters, :internals], name = "Summary", append_chains = false)
@test all_sections_dfs isa Vector{<:ChainDataFrame}
for (i, all_sections_df) in enumerate(all_sections_dfs)
@test all_sections_df[:,:parameters] == [:a, :b, :c, :d, :e, :f, :g, :h]
@test size(all_sections_df) == (8, 8)
@test all_sections_df.name == "Summary (Chain $i)"
end

two_parms_two_funs_df = summarize(chns[[:a, :b]], mean, std)
@test two_parms_two_funs_df[:, :parameters] == [:a, :b]
Expand Down

2 comments on commit 82def13

@cpfiffer
Copy link
Member

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

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 v6.0.3 -m "<description of version>" 82def13b4ed4ae442d1fd655dfe3644b5113da74
git push origin v6.0.3

Please sign in to comment.