Skip to content

Commit 691e01d

Browse files
committed
Improve submodel error message
1 parent c79fe47 commit 691e01d

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/context_implementations.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,8 @@ Falls back to `tilde_observe!!(context, right, left, vi)` ignoring the informati
109109
and indices; if needed, these can be accessed through this function, though.
110110
"""
111111
function tilde_observe!!(::DefaultContext, right, left, vn, vi)
112-
right isa DynamicPPL.Submodel && throw(
113-
ArgumentError(
114-
"`~` with a submodel on the right-hand side of an observe statement is not supported",
115-
),
116-
)
112+
right isa DynamicPPL.Submodel &&
113+
throw(ArgumentError("`x ~ to_submodel(...)` is not supported when `x` is observed"))
117114
vi = accumulate_observe!!(vi, right, left, vn)
118115
return left, vi
119116
end

src/model.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ julia> # However, it's not possible to condition `inner` directly.
258258
conditioned_model_fail = model | (inner = 1.0, );
259259
260260
julia> conditioned_model_fail()
261-
ERROR: ArgumentError: `~` with a model on the right-hand side of an observe statement is not supported
261+
ERROR: ArgumentError: `x ~ to_submodel(...)` is not supported when `x` is observed
262262
[...]
263263
```
264264
"""

src/submodel.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ julia> @model illegal_likelihood() = a ~ to_submodel(inner())
144144
illegal_likelihood (generic function with 2 methods)
145145
146146
julia> model = illegal_likelihood() | (a = 1.0,);
147-
julia> model()
148-
ERROR: ArgumentError: `~` with a model on the right-hand side of an observe statement is not supported
147+
julia> model(a)
148+
ERROR: ArgumentError: `x ~ to_submodel(...)` is not supported when `x` is observed
149149
[...]
150150
```
151151
"""

0 commit comments

Comments
 (0)