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

CompatHelper: bump compat for "AdvancedPS" to "0.2" #1610

Merged
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Turing"
uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
version = "0.15.22"
version = "0.15.23"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down Expand Up @@ -36,7 +36,7 @@ ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"
AbstractMCMC = "3.2"
AdvancedHMC = "0.2.24"
AdvancedMH = "0.6"
AdvancedPS = "0.1"
AdvancedPS = "0.2"
AdvancedVI = "0.1"
BangBang = "0.3"
Bijectors = "0.8, 0.9"
Expand Down
22 changes: 11 additions & 11 deletions src/inference/AdvancedSMC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end
"""
SMC(space...)
SMC([resampler = AdvancedPS.ResampleWithESSThreshold(), space = ()])
SMC([resampler = AdvancedPS.resample, ]threshold[, space = ()])
SMC([resampler = AdvancedPS.resample_systematic, ]threshold[, space = ()])

Create a sequential Monte Carlo sampler of type [`SMC`](@ref) for the variables in `space`.

Expand All @@ -37,7 +37,7 @@ end
function SMC(resampler, threshold::Real, space::Tuple = ())
return SMC(AdvancedPS.ResampleWithESSThreshold(resampler, threshold), space)
end
SMC(threshold::Real, space::Tuple = ()) = SMC(AdvancedPS.resample, threshold, space)
SMC(threshold::Real, space::Tuple = ()) = SMC(AdvancedPS.resample_systematic, threshold, space)

# If only the space is defined
SMC(space::Symbol...) = SMC(space)
Expand Down Expand Up @@ -100,7 +100,7 @@ function AbstractMCMC.sample(
end

function DynamicPPL.initialstep(
::AbstractRNG,
rng::AbstractRNG,
model::AbstractModel,
spl::Sampler{<:SMC},
vi::AbstractVarInfo;
Expand All @@ -119,7 +119,7 @@ function DynamicPPL.initialstep(
)

# Perform particle sweep.
logevidence = AdvancedPS.sweep!(particles, spl.alg.resampler)
logevidence = AdvancedPS.sweep!(rng, particles, spl.alg.resampler)

# Extract the first particle and its weight.
particle = particles.vals[1]
Expand Down Expand Up @@ -180,7 +180,7 @@ end
"""
PG(n, space...)
PG(n, [resampler = AdvancedPS.ResampleWithESSThreshold(), space = ()])
PG(n, [resampler = AdvancedPS.resample, ]threshold[, space = ()])
PG(n, [resampler = AdvancedPS.resample_systematic, ]threshold[, space = ()])

Create a Particle Gibbs sampler of type [`PG`](@ref) with `n` particles for the variables
in `space`.
Expand All @@ -201,7 +201,7 @@ function PG(nparticles::Int, resampler, threshold::Real, space::Tuple = ())
return PG(nparticles, AdvancedPS.ResampleWithESSThreshold(resampler, threshold), space)
end
function PG(nparticles::Int, threshold::Real, space::Tuple = ())
return PG(nparticles, AdvancedPS.resample, threshold, space)
return PG(nparticles, AdvancedPS.resample_systematic, threshold, space)
end

# If only the number of particles and the space is defined
Expand Down Expand Up @@ -258,11 +258,11 @@ function DynamicPPL.initialstep(
)

# Perform a particle sweep.
logevidence = AdvancedPS.sweep!(particles, spl.alg.resampler)
logevidence = AdvancedPS.sweep!(rng, particles, spl.alg.resampler)

# Pick a particle to be retained.
Ws = AdvancedPS.getweights(particles)
indx = AdvancedPS.randcat(Ws)
indx = AdvancedPS.randcat(rng, Ws)
reference = particles.vals[indx]

# Compute the first transition.
Expand All @@ -273,7 +273,7 @@ function DynamicPPL.initialstep(
end

function AbstractMCMC.step(
::AbstractRNG,
rng::AbstractRNG,
model::AbstractModel,
spl::Sampler{<:PG},
vi::AbstractVarInfo;
Expand Down Expand Up @@ -301,11 +301,11 @@ function AbstractMCMC.step(
particles = AdvancedPS.ParticleContainer(x)

# Perform a particle sweep.
logevidence = AdvancedPS.sweep!(particles, spl.alg.resampler)
logevidence = AdvancedPS.sweep!(rng, particles, spl.alg.resampler)

# Pick a particle to be retained.
Ws = AdvancedPS.getweights(particles)
indx = AdvancedPS.randcat(Ws)
indx = AdvancedPS.randcat(rng, Ws)
newreference = particles.vals[indx]

# Compute the transition.
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
[compat]
AbstractMCMC = "3.2"
AdvancedMH = "0.6"
AdvancedPS = "0.1"
AdvancedPS = "0.2"
AdvancedVI = "0.1"
Clustering = "0.14"
CmdStan = "6.0.8"
Expand Down