Skip to content

Commit

Permalink
Fix failing tests (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion authored Apr 8, 2021
1 parent b0da9f1 commit 2d710cb
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 26 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 = "4.7.3"
version = "4.7.4"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
8 changes: 7 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ makedocs(
format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"),
modules = [MCMCChains],
strict = true,
checkdocs = :exports
checkdocs = :exports,
# https://github.com/JuliaLang/julia/pull/37085#issuecomment-683356098
doctestfilters = [
r"{([a-zA-Z0-9]+,\s?)+[a-zA-Z0-9]+}",
r"(Array{[a-zA-Z0-9]+,\s?1}|Vector{[a-zA-Z0-9]+})",
r"(Array{[a-zA-Z0-9]+,\s?2}|Matrix{[a-zA-Z0-9]+})",
]
)

deploydocs(repo = "github.com/TuringLang/MCMCChains.jl.git", push_preview=true)
39 changes: 21 additions & 18 deletions src/chains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ Return a new chain with only a specific `section` or multiple `sections` pulled
julia> chn = Chains(rand(100, 2, 1), [:a, :b], Dict(:internals => [:a]));
julia> names(chn)
2-element Array{Symbol,1}:
2-element Vector{Symbol}:
:a
:b
julia> chn2 = Chains(chn, :internals);
julia> names(chn2)
1-element Array{Symbol,1}:
1-element Vector{Symbol}:
:a
```
"""
Expand Down Expand Up @@ -122,7 +122,7 @@ If the chain contains a parameter of name `:sym` it will be returned as well.
julia> chn = Chains(rand(100, 2, 2), ["A[1]", "A[2]"]);
julia> namesingroup(chn, :A)
2-element Array{Symbol,1}:
2-element Vector{Symbol}:
Symbol("A[1]")
Symbol("A[2]")
```
Expand Down Expand Up @@ -192,14 +192,15 @@ names as the values.
Passing `flatten=true` will return a `NamedTuple` with keys ungrouped.
# Example
```julia
julia> chn = Chains([1:5 6:10]);
```jldoctest
julia> chn = Chains([1:2 3:4]);
julia> get(chn, :param_1)
(param_1 = [1; 2; … ; 4; 5],)
(param_1 = [1; 2],)
julia> get(chn, [:param_1, :param_2])
(param_2 = [6; 7; … ; 9; 10], param_1 = [1; 2; … ; 4; 5])
julia> get(chn, [:param_2])
(param_2 = [3; 4],)
julia> get(chn, :param_1; flatten=true)
(param_1 = 1,)
Expand Down Expand Up @@ -239,14 +240,15 @@ Return all parameters in a given section(s) as a `NamedTuple`.
Passing `flatten=true` will return a `NamedTuple` with keys ungrouped.
# Example
```julia
julia> chn = Chains([1:5 6:10], [:a, :b], Dict(:internals => [:a]));
julia> x = get(chn; section=:parameters)
(b = [6; 7; … ; 9; 10],)
```jldoctest
julia> chn = Chains([1:2 3:4], [:a, :b], Dict(:internals => [:a]));
julia> x = get(chn; section=[:internals, :parameters])
(a = [1; 2; … ; 4; 5], b = [6; 7; … ; 9; 10])
julia> get(chn; section=:parameters)
(b = [3; 4],)
julia> get(chn; section=[:internals])
(a = [1; 2],)
```
"""
function Base.get(
Expand Down Expand Up @@ -284,7 +286,8 @@ in their name (as in "P[1]") will be grouped into the returned value as P.
Passing `flatten=true` will return a `NamedTuple` with keys ungrouped.
# Example
```julia
```jldoctest
julia> chn = Chains(1:5);
julia> x = get_params(chn);
Expand All @@ -293,7 +296,7 @@ julia> x.param_1
2-dimensional AxisArray{Int64,2,...} with axes:
:iter, 1:1:5
:chain, 1:1
And data, a 5×1 Array{Int64,2}:
And data, a 5×1 Matrix{Int64}:
1
2
3
Expand Down Expand Up @@ -690,14 +693,14 @@ julia> chn = Chains(rand(100, 2, 2), ["one", "two"]);
julia> chn2 = replacenames(chn, "one" => "A");
julia> names(chn2)
2-element Array{Symbol,1}:
2-element Vector{Symbol}:
:A
:two
julia> chn3 = replacenames(chn2, Dict("A" => "one", "two" => "B"));
julia> names(chn3)
2-element Array{Symbol,1}:
2-element Vector{Symbol}:
:one
:B
```
Expand Down
8 changes: 4 additions & 4 deletions src/gelmandiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ function gelmandiag(
results = gelmandiag(psi; alpha = alpha, kwargs...)

# Create a named tuple with the results.
colnames = (:psrf, Symbol(100 * (1 - alpha / 2), :%))
nt = (; parameters = names(_chains), zip(colnames, results)...)
sym = Symbol(100 * (1 - alpha / 2), :%)
nt = (; :parameters => names(_chains), :psrf => results.psrf, sym => results.psrfci)

return ChainDataFrame("Gelman, Rubin, and Brooks Diagnostic", nt)
end
Expand All @@ -124,8 +124,8 @@ function gelmandiag_multivariate(
results = gelmandiag_multivariate(psi; alpha = alpha, kwargs...)

# Create a named tuple with the results.
colnames = (:psrf, Symbol(100 * (1 - alpha / 2), :%))
nt = (; parameters = names(_chains), zip(colnames, (results.psrf, results.psrfci))...)
sym = Symbol(100 * (1 - alpha / 2), :%)
nt = (; :parameters => names(_chains), :psrf => results.psrf, sym => results.psrfci)

return ChainDataFrame("Gelman, Rubin, and Brooks Diagnostic", nt),
results.multivariate
Expand Down
2 changes: 1 addition & 1 deletion src/stats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ end

function chaindataframe_changerate(name, names_of_params, chains; kwargs...)
# Compute the change rates.
changerates, mvchangerate = chains
changerates, mvchangerate = changerate(chains)

# Summarize the results in a named tuple.
nt = (; zip(names_of_params, changerates)..., multivariate = mvchangerate)
Expand Down
11 changes: 10 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ Random.seed!(0)
:(using MCMCChains);
recursive=true
)
doctest(MCMCChains)

doctest(
MCMCChains;
# https://github.com/JuliaLang/julia/pull/37085#issuecomment-683356098
doctestfilters = [
r"{([a-zA-Z0-9]+,\s?)+[a-zA-Z0-9]+}",
r"(Array{[a-zA-Z0-9]+,\s?1}|Vector{[a-zA-Z0-9]+})",
r"(Array{[a-zA-Z0-9]+,\s?2}|Matrix{[a-zA-Z0-9]+})",
],
)
end

# run tests for effective sample size
Expand Down

2 comments on commit 2d710cb

@devmotion
Copy link
Member 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/33853

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 v4.7.4 -m "<description of version>" 2d710cb91dbb7d39698c8ae76e5e5141b48e16db
git push origin v4.7.4

Please sign in to comment.