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 1
1
name = " AdvancedPS"
2
2
uuid = " 576499cb-2369-40b2-a588-c64705576edc"
3
3
authors = [" TuringLang" ]
4
- version = " 0.2.4 "
4
+ version = " 0.3 "
5
5
6
6
[deps ]
7
7
AbstractMCMC = " 80f14c24-f653-4e6a-9b94-39d6b0f70001"
@@ -13,6 +13,6 @@ StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
13
13
[compat ]
14
14
AbstractMCMC = " 2, 3"
15
15
Distributions = " 0.23, 0.24, 0.25"
16
- Libtask = " 0.5.3 "
16
+ Libtask = " 0.6 "
17
17
StatsFuns = " 0.9"
18
18
julia = " 1.3"
Original file line number Diff line number Diff line change 6
6
const Particle = Trace
7
7
8
8
function 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)
16
10
17
11
# add backward reference
18
12
newtrace = Trace (f, ctask)
48
42
# Create new task and copy randomness
49
43
function forkr (trace:: Trace )
50
44
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)
58
46
59
47
# add backward reference
60
48
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.
6
6
function observe (dist:: Distributions.Distribution , x)
7
7
return Libtask. produce (Distributions. loglikelihood (dist, x))
8
8
end
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"
8
8
[compat ]
9
9
AbstractMCMC = " 2, 3"
10
10
Distributions = " 0.24, 0.25"
11
- Libtask = " 0.5 "
11
+ Libtask = " 0.6 "
12
12
julia = " 1.3"
Original file line number Diff line number Diff line change 12
12
function fpc (logp)
13
13
f = let logp = logp
14
14
() -> begin
15
- while true
15
+ for _ in 1 : 100
16
16
produce (logp)
17
17
end
18
18
end
98
98
function f2 ()
99
99
t = TArray (Int, 1 )
100
100
t[1 ] = 0
101
- while true
101
+ for _ in 1 : 100
102
102
n[] += 1
103
103
produce (t[1 ])
104
104
n[] += 1
Original file line number Diff line number Diff line change 59
59
end
60
60
end
61
61
62
- @test_throws ErrorException sample (FailSMCModel (), AdvancedPS. SMC (100 ))
62
+ # @test_throws ErrorException sample(FailSMCModel(), AdvancedPS.SMC(100))
63
63
end
64
64
65
65
@testset " logevidence" begin
You can’t perform that action at this time.
0 commit comments