@@ -231,20 +231,11 @@ function record_varname!(context::DebugContext, varname::VarName, dist)
231231 end
232232end
233233
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-
243234_has_missings (x) = ismissing (x)
244235function _has_missings (x:: AbstractArray )
245236 # Can't just use `any` because `x` might contain `undef`.
246237 for i in eachindex (x)
247- if _isassigned (x, i) && _has_missings (x[i])
238+ if isassigned (x, i) && _has_missings (x[i])
248239 return true
249240 end
250241 end
@@ -293,9 +284,18 @@ function record_pre_tilde_observe!(context::DebugContext, left, dist, varinfo)
293284 # Check for `missing`s; these should not end up here.
294285 if _has_missings (left)
295286 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." ,
299299 )
300300 end
301301end
474474
475475Check that `model` is valid, warning about any potential issues.
476476
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
478478and details of which types of checks are performed.
479479
480480# Returns
0 commit comments