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

Fix method ambiguity issues #123

Merged
merged 3 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.1"
version = "4.4.2"

[deps]
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
Expand Down
17 changes: 13 additions & 4 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,28 @@ be specified with the `chain_type` argument.
By default, this method returns `samples`.
"""
function bundle_samples(
samples, ::AbstractModel, ::AbstractSampler, ::Any, ::Type; kwargs...
samples, model::AbstractModel, sampler::AbstractSampler, state, ::Type{T}; kwargs...
) where {T}
# dispatch to internal method for default implementations to fix
# method ambiguity issues (see #120)
return _bundle_samples(samples, model, sampler, state, T; kwargs...)
end

function _bundle_samples(
samples, @nospecialize(::AbstractModel), @nospecialize(::AbstractSampler), @nospecialize(::Any), ::Type; kwargs...
devmotion marked this conversation as resolved.
Show resolved Hide resolved
)
return samples
end

function bundle_samples(
samples::Vector, ::AbstractModel, ::AbstractSampler, ::Any, ::Type{Vector{T}}; kwargs...
devmotion marked this conversation as resolved.
Show resolved Hide resolved
function _bundle_samples(
samples::Vector, @nospecialize(::AbstractModel), @nospecialize(::AbstractSampler), @nospecialize(::Any), ::Type{Vector{T}}; kwargs...
devmotion marked this conversation as resolved.
Show resolved Hide resolved
) where {T}
return map(samples) do sample
convert(T, sample)
end
end


devmotion marked this conversation as resolved.
Show resolved Hide resolved
"""
step(rng, model, sampler[, state; kwargs...])

Expand Down