@@ -231,20 +231,11 @@ function record_varname!(context::DebugContext, varname::VarName, dist)
231
231
end
232
232
end
233
233
234
- # tilde
235
- _isassigned (x:: AbstractArray , i) = isassigned (x, i)
236
- # HACK(torfjelde): Julia v1.7 only supports `isassigned(::AbstractArray, ::Int...)`.
237
- # TODO (torfjelde): Determine exactly in which version this change was introduced.
238
- if VERSION < v " v1.9.0-alpha1"
239
- _isassigned (x:: AbstractArray , inds:: Tuple ) = isassigned (x, inds... )
240
- _isassigned (x:: AbstractArray , idx:: CartesianIndex ) = _isassigned (x, Tuple (idx))
241
- end
242
-
243
234
_has_missings (x) = ismissing (x)
244
235
function _has_missings (x:: AbstractArray )
245
236
# Can't just use `any` because `x` might contain `undef`.
246
237
for i in eachindex (x)
247
- if _isassigned (x, i) && _has_missings (x[i])
238
+ if isassigned (x, i) && _has_missings (x[i])
248
239
return true
249
240
end
250
241
end
@@ -293,9 +284,18 @@ function record_pre_tilde_observe!(context::DebugContext, left, dist, varinfo)
293
284
# Check for `missing`s; these should not end up here.
294
285
if _has_missings (left)
295
286
error (
296
- " Encountered missing value(s) in observe!\n " *
297
- " Remember that using `missing` to de-condition a variable is only " *
298
- " supported for univariate distributions, not for $dist " ,
287
+ " Encountered `missing` value(s) on the left-hand side" *
288
+ " of an observe statement. Using `missing` to de-condition" *
289
+ " a variable is only supported for univariate distributions," *
290
+ " not for $dist ." ,
291
+ )
292
+ end
293
+ # Check for NaN's as well
294
+ if any (isnan, left)
295
+ error (
296
+ " Encountered a NaN value on the left-hand side of an" *
297
+ " observe statement; this may indicate that your data" *
298
+ " contain NaN values." ,
299
299
)
300
300
end
301
301
end
474
474
475
475
Check that `model` is valid, warning about any potential issues.
476
476
477
- See [`check_model_and_trace`](@ref) for more details on supported keword arguments
477
+ See [`check_model_and_trace`](@ref) for more details on supported keyword arguments
478
478
and details of which types of checks are performed.
479
479
480
480
# Returns
0 commit comments