Skip to content

Commit 8fbcb20

Browse files
Proper type dispatch (#91)
* Proper type dispatch * Bump
1 parent 3700563 commit 8fbcb20

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AdvancedPS"
22
uuid = "576499cb-2369-40b2-a588-c64705576edc"
33
authors = ["TuringLang"]
4-
version = "0.5.2"
4+
version = "0.5.3"
55

66
[deps]
77
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"

src/container.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ end
6262
Update reference trajectory. Defaults to `nothing`
6363
"""
6464
function update_ref!(
65-
particle::Trace, pc::ParticleContainer, sampler::AbstractParticleSampler
66-
)
65+
particle::Trace, pc::ParticleContainer, sampler::T
66+
) where {T<:AbstractMCMC.AbstractSampler}
6767
return nothing
6868
end
6969

@@ -171,11 +171,11 @@ of the particle `weights`. For Particle Gibbs sampling, one can provide a refere
171171
function resample_propagate!(
172172
::Random.AbstractRNG,
173173
pc::ParticleContainer,
174-
sampler::AbstractParticleSampler,
174+
sampler::T,
175175
randcat=DEFAULT_RESAMPLER,
176176
ref::Union{Particle,Nothing}=nothing;
177177
weights=getweights(pc),
178-
)
178+
) where {T<:AbstractMCMC.AbstractSampler}
179179
# sample ancestor indices
180180
n = length(pc)
181181
nresamples = ref === nothing ? n : n - 1
@@ -233,11 +233,11 @@ end
233233
function resample_propagate!(
234234
rng::Random.AbstractRNG,
235235
pc::ParticleContainer,
236-
sampler::AbstractParticleSampler,
236+
sampler::T,
237237
resampler::ResampleWithESSThreshold,
238238
ref::Union{Particle,Nothing}=nothing;
239239
weights=getweights(pc),
240-
)
240+
) where {T<:AbstractMCMC.AbstractSampler}
241241
# Compute the effective sample size ``1 / ∑ wᵢ²`` with normalized weights ``wᵢ``
242242
ess = inv(sum(abs2, weights))
243243

0 commit comments

Comments
 (0)