Skip to content

Commit 348625d

Browse files
committed
Fix for bug in MiniBatchContext (#302)
One of my previous PRs introduced a bug for `MiniBatchContext`; this fixes said bug. It also removes a redundant impl of `tilde_observe` for `SamplingContext`.
1 parent e381f3e commit 348625d

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DynamicPPL"
22
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
3-
version = "0.14.0"
3+
version = "0.14.1"
44

55
[deps]
66
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"

src/context_implementations.jl

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,6 @@ function tilde_assume!(context, right, vn, inds, vi)
143143
end
144144

145145
# observe
146-
"""
147-
tilde_observe(context::SamplingContext, right, left, vname, vinds, vi)
148-
149-
Handle observed variables with a `context` associated with a sampler.
150-
151-
Falls back to
152-
```julia
153-
tilde_observe(context.rng, context.context, context.sampler, right, left, vname, vinds, vi)
154-
```
155-
"""
156-
function tilde_observe(context::SamplingContext, right, left, vname, vinds, vi)
157-
return tilde_observe(
158-
context.rng, context.context, context.sampler, right, left, vname, vinds, vi
159-
)
160-
end
161-
162146
"""
163147
tilde_observe(context::SamplingContext, right, left, vi)
164148
@@ -187,8 +171,7 @@ function tilde_observe(context::MiniBatchContext, right, left, vi)
187171
return context.loglike_scalar * tilde_observe(context.context, right, left, vi)
188172
end
189173
function tilde_observe(context::MiniBatchContext, sampler, right, left, vi)
190-
return context.loglike_scalar *
191-
tilde_observe(context.context, sampler, right, left, vname, vi)
174+
return context.loglike_scalar * tilde_observe(context.context, sampler, right, left, vi)
192175
end
193176

194177
# `PrefixContext`

test/contexts.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ end
226226
end
227227
end
228228

229+
@testset "Evaluation" begin
230+
@testset "$context" for context in contexts
231+
# Just making sure that we can actually sample with each of the contexts.
232+
@test (gdemo_default(SamplingContext(context)); true)
233+
end
234+
end
235+
229236
@testset "PrefixContext" begin
230237
ctx = @inferred PrefixContext{:f}(
231238
PrefixContext{:e}(

0 commit comments

Comments
 (0)