Skip to content

Commit 9f8522f

Browse files
authored
Merge pull request #31 from FredericWantiez/master
TracedRNG type
2 parents 51c18d4 + ec38abe commit 9f8522f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/container.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
struct Trace{F,U,N,V<:Random123.AbstractR123{U}}
1+
struct Trace{F,R<:TracedRNG}
22
f::F
33
ctask::Libtask.CTask
4-
rng::TracedRNG{U,N,V}
4+
rng::R
55
end
66

77
const Particle = Trace
@@ -95,13 +95,13 @@ Data structure for particle filters
9595
- normalise!(pc::ParticleContainer)
9696
- consume(pc::ParticleContainer): return incremental likelihood
9797
"""
98-
mutable struct ParticleContainer{T<:Particle,U,N,V<:Random123.AbstractR123{U}}
98+
mutable struct ParticleContainer{T<:Particle,R<:TracedRNG}
9999
"Particles."
100100
vals::Vector{T}
101101
"Unnormalized logarithmic weights."
102102
logWs::Vector{Float64}
103103
"Traced RNG to replay the resampling step"
104-
rng::TracedRNG{U,N,V}
104+
rng::R
105105
end
106106

107107
function ParticleContainer(particles::Vector{<:Particle})
@@ -207,6 +207,7 @@ function update_keys!(pc::ParticleContainer, ref::Union{Particle,Nothing}=nothin
207207
k = split(pi.rng.rng.key)
208208
Random.seed!(pi.rng, k[1])
209209
end
210+
return nothing
210211
end
211212

212213
"""

test/container.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Create a resumable function that always returns the same log probability.
1212
function fpc(logp)
1313
f = let logp = logp
14-
(rng) -> begin
14+
rng -> begin
1515
while true
1616
produce(logp)
1717
end

0 commit comments

Comments
 (0)