Skip to content

Commit

Permalink
Proper type dispatch (#91)
Browse files Browse the repository at this point in the history
* Proper type dispatch

* Bump
  • Loading branch information
FredericWantiez authored Nov 4, 2023
1 parent 3700563 commit 8fbcb20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AdvancedPS"
uuid = "576499cb-2369-40b2-a588-c64705576edc"
authors = ["TuringLang"]
version = "0.5.2"
version = "0.5.3"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down
12 changes: 6 additions & 6 deletions src/container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ end
Update reference trajectory. Defaults to `nothing`
"""
function update_ref!(
particle::Trace, pc::ParticleContainer, sampler::AbstractParticleSampler
)
particle::Trace, pc::ParticleContainer, sampler::T
) where {T<:AbstractMCMC.AbstractSampler}
return nothing
end

Expand Down Expand Up @@ -171,11 +171,11 @@ of the particle `weights`. For Particle Gibbs sampling, one can provide a refere
function resample_propagate!(
::Random.AbstractRNG,
pc::ParticleContainer,
sampler::AbstractParticleSampler,
sampler::T,
randcat=DEFAULT_RESAMPLER,
ref::Union{Particle,Nothing}=nothing;
weights=getweights(pc),
)
) where {T<:AbstractMCMC.AbstractSampler}
# sample ancestor indices
n = length(pc)
nresamples = ref === nothing ? n : n - 1
Expand Down Expand Up @@ -233,11 +233,11 @@ end
function resample_propagate!(
rng::Random.AbstractRNG,
pc::ParticleContainer,
sampler::AbstractParticleSampler,
sampler::T,
resampler::ResampleWithESSThreshold,
ref::Union{Particle,Nothing}=nothing;
weights=getweights(pc),
)
) where {T<:AbstractMCMC.AbstractSampler}
# Compute the effective sample size ``1 / ∑ wᵢ²`` with normalized weights ``wᵢ``
ess = inv(sum(abs2, weights))

Expand Down

2 comments on commit 8fbcb20

@yebai
Copy link
Member

@yebai yebai commented on 8fbcb20 Nov 4, 2023

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

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.5.3 -m "<description of version>" 8fbcb20e6f462197a7ebb6dbd0ddf89651d27b32
git push origin v0.5.3

Please sign in to comment.