@@ -11,20 +11,8 @@ function _error_msg()
11
11
return " This macro is only for use in the `@model` macro and not for external use."
12
12
end
13
13
14
-
15
-
16
- # Check if the right-hand side is a distribution.
17
- function assert_dist (dist; msg)
18
- isa (dist, Distribution) || throw (ArgumentError (msg))
19
- end
20
- function assert_dist (dist:: AbstractVector ; msg)
21
- all (d -> isa (d, Distribution), dist) || throw (ArgumentError (msg))
22
- end
23
-
24
- function wrong_dist_errormsg (l)
25
- return " Right-hand side of a ~ must be subtype of Distribution or a vector of " *
26
- " Distributions on line $(l) ."
27
- end
14
+ const DISTMSG = " Right-hand side of a ~ must be subtype of Distribution or a vector of " *
15
+ " Distributions."
28
16
29
17
"""
30
18
isassumption(model, expr)
@@ -260,14 +248,14 @@ function replace_tilde!(model_info)
260
248
dotargs = getargs_dottilde (x)
261
249
if dotargs != = nothing
262
250
L, R = dotargs
263
- return generate_dot_tilde (L, R, model_info)
251
+ return Base . remove_linenums! ( generate_dot_tilde (L, R, model_info) )
264
252
end
265
253
266
254
# Check tilde.
267
255
args = getargs_tilde (x)
268
256
if args != = nothing
269
257
L, R = args
270
- return generate_tilde (L, R, model_info)
258
+ return Base . remove_linenums! ( generate_tilde (L, R, model_info) )
271
259
end
272
260
273
261
return x
@@ -296,7 +284,8 @@ function generate_tilde(left, right, model_info)
296
284
297
285
@gensym tmpright
298
286
top = [:($ tmpright = $ right),
299
- :($ (DynamicPPL. assert_dist)($ tmpright, msg = $ (wrong_dist_errormsg (@__LINE__ ))))]
287
+ :($ tmpright isa Union{$ Distribution,AbstractVector{<: $Distribution }}
288
+ || throw (ArgumentError ($ DISTMSG)))]
300
289
301
290
if left isa Symbol || left isa Expr
302
291
@gensym out vn inds
@@ -358,7 +347,8 @@ function generate_dot_tilde(left, right, model_info)
358
347
359
348
@gensym tmpright
360
349
top = [:($ tmpright = $ right),
361
- :($ (DynamicPPL. assert_dist)($ tmpright, msg = $ (wrong_dist_errormsg (@__LINE__ ))))]
350
+ :($ tmpright isa Union{$ Distribution,AbstractVector{<: $Distribution }}
351
+ || throw (ArgumentError ($ DISTMSG)))]
362
352
363
353
if left isa Symbol || left isa Expr
364
354
@gensym out vn inds
0 commit comments