Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove overly specialized bundle_samples #120

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
keywords = ["markov chain monte carlo", "probablistic programming"]
license = "MIT"
desc = "A lightweight interface for common MCMC methods."
version = "4.4.0"
version = "4.5.0"

[deps]
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
Expand Down
8 changes: 0 additions & 8 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ function bundle_samples(
return samples
end

function bundle_samples(
samples::Vector, ::AbstractModel, ::AbstractSampler, ::Any, ::Type{Vector{T}}; kwargs...
) where {T}
return map(samples) do sample
convert(T, sample)
end
end

"""
step(rng, model, sampler[, state; kwargs...])

Expand Down
15 changes: 0 additions & 15 deletions test/sample.jl
Original file line number Diff line number Diff line change
Expand Up @@ -553,21 +553,6 @@
@test all(chain[i].b == ref_chain[i].b for i in 1:N)
end

@testset "Sample vector of `NamedTuple`s" begin
chain = sample(MyModel(), MySampler(), 1_000; chain_type=Vector{NamedTuple})
# Check output type
@test chain isa Vector{<:NamedTuple}
@test length(chain) == 1_000
@test all(keys(x) == (:a, :b) for x in chain)

# Check some statistical properties
@test ismissing(chain[1].a)
@test mean(x.a for x in view(chain, 2:1_000)) ≈ 0.5 atol = 6e-2
@test var(x.a for x in view(chain, 2:1_000)) ≈ 1 / 12 atol = 1e-2
@test mean(x.b for x in chain) ≈ 0 atol = 0.1
@test var(x.b for x in chain) ≈ 1 atol = 0.15
end

@testset "Testing callbacks" begin
function count_iterations(
rng, model, sampler, sample, state, i; iter_array, kwargs...
Expand Down
3 changes: 0 additions & 3 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ function AbstractMCMC.chainscat(
return vcat(chain, chains...)
end

# Conversion to NamedTuple
Base.convert(::Type{NamedTuple}, x::MySample) = (a=x.a, b=x.b)

# Gaussian log density (without additive constants)
# Without LogDensityProblems.jl interface
mylogdensity(x) = -sum(abs2, x) / 2
Expand Down