File tree Expand file tree Collapse file tree 6 files changed +15
-20
lines changed Expand file tree Collapse file tree 6 files changed +15
-20
lines changed Original file line number Diff line number Diff line change 11name = " AdvancedPS"
22uuid = " 576499cb-2369-40b2-a588-c64705576edc"
33authors = [" TuringLang" ]
4- version = " 0.2.4 "
4+ version = " 0.3 "
55
66[deps ]
77AbstractMCMC = " 80f14c24-f653-4e6a-9b94-39d6b0f70001"
@@ -13,6 +13,6 @@ StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
1313[compat ]
1414AbstractMCMC = " 2, 3"
1515Distributions = " 0.23, 0.24, 0.25"
16- Libtask = " 0.5.3 "
16+ Libtask = " 0.6 "
1717StatsFuns = " 0.9"
1818julia = " 1.3"
Original file line number Diff line number Diff line change 66const Particle = Trace
77
88function Trace (f)
9- ctask = let f = f
10- Libtask. CTask () do
11- res = f ()
12- Libtask. produce (nothing )
13- return res
14- end
15- end
9+ ctask = Libtask. CTask (f)
1610
1711 # add backward reference
1812 newtrace = Trace (f, ctask)
4842# Create new task and copy randomness
4943function forkr (trace:: Trace )
5044 newf = reset_model (trace. f)
51- ctask = let f = trace. ctask. task. code
52- Libtask. CTask () do
53- res = f ()
54- Libtask. produce (nothing )
55- return res
56- end
57- end
45+ ctask = Libtask. CTask (trace. ctask)
5846
5947 # add backward reference
6048 newtrace = Trace (newf, ctask)
Original file line number Diff line number Diff line change @@ -6,3 +6,10 @@ Observe sample `x` from distribution `dist` and yield its log-likelihood value.
66function observe (dist:: Distributions.Distribution , x)
77 return Libtask. produce (Distributions. loglikelihood (dist, x))
88end
9+
10+ function (instr:: Libtask.Instruction{typeof(observe)} )()
11+ dist = Libtask. val (instr. input[1 ])
12+ x = Libtask. val (instr. input[2 ])
13+ result = Distributions. loglikelihood (dist, x)
14+ return Libtask. internal_produce (instr, result)
15+ end
Original file line number Diff line number Diff line change @@ -8,5 +8,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
88[compat ]
99AbstractMCMC = " 2, 3"
1010Distributions = " 0.24, 0.25"
11- Libtask = " 0.5 "
11+ Libtask = " 0.6 "
1212julia = " 1.3"
Original file line number Diff line number Diff line change 1212 function fpc (logp)
1313 f = let logp = logp
1414 () -> begin
15- while true
15+ for _ in 1 : 100
1616 produce (logp)
1717 end
1818 end
9898 function f2 ()
9999 t = TArray (Int, 1 )
100100 t[1 ] = 0
101- while true
101+ for _ in 1 : 100
102102 n[] += 1
103103 produce (t[1 ])
104104 n[] += 1
Original file line number Diff line number Diff line change 5959 end
6060 end
6161
62- @test_throws ErrorException sample (FailSMCModel (), AdvancedPS. SMC (100 ))
62+ # @test_throws ErrorException sample(FailSMCModel(), AdvancedPS.SMC(100))
6363 end
6464
6565 @testset " logevidence" begin
You can’t perform that action at this time.
0 commit comments