Skip to content

Commit

Permalink
Add test, fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
FredericWantiez committed Nov 3, 2023
1 parent 8305ab4 commit 20aab8b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 1 addition & 2 deletions ext/AdvancedPSLibtaskExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ function AbstractMCMC.step(
# Create reference trajectory.
AdvancedPS.forkr(copy(state.trajectory))
else
println(model)
trng = AdvancedPS.TracedRNG()
trace = AdvancedPS.Trace(deepcopy(model), trng)
AdvancedPS.addreference!(trace.model.ctask.task, trace) # Do we need it here ?
AdvancedPS.addreference!(trace.model.ctask.task, trace) # TODO: Do we need it here ?
trace
end
end
Expand Down
15 changes: 15 additions & 0 deletions test/container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,21 @@
@test consume(a.model.ctask) == 4
end

@testset "current trace" begin
struct TaskIdModel <: AdvancedPS.AbstractGenericModel end

function (model::TaskIdModel)(rng::Random.AbstractRNG)
# Just print the task it's running in
id = objectid(AdvancedPS.current_trace())
return Libtask.produce(id)
end

trace = AdvancedPS.Trace(TaskIdModel(), AdvancedPS.TracedRNG())
AdvancedPS.addreference!(trace.model.ctask.task, trace)

@test AdvancedPS.advance!(trace, false) === objectid(trace)
end

@testset "seed container" begin
seed = 1
n = 3
Expand Down

0 comments on commit 20aab8b

Please sign in to comment.