Skip to content

Commit dfdc155

Browse files
torfjeldeyebai
andauthored
Fix for check_model on Julia <1.9 (#631)
* Added work-around for Julia v1.7 and lower only supporting `isassigned(x, ::Int...)` * Add the work-around for `isassigned` for Julia <v1.9.0-alpha1 as it seems that is when it was introduced JuliaLang/julia@c889fbc * Update Project.toml --------- Co-authored-by: Hong Ge <[email protected]>
1 parent 123d7bf commit dfdc155

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Project.toml

+1-1
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.28"
3+
version = "0.28.1"
44

55
[deps]
66
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/debug_utils.jl

+9-1
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,19 @@ function record_varname!(context::DebugContext, varname::VarName, dist)
286286
end
287287

288288
# tilde
289+
_isassigned(x::AbstractArray, i) = isassigned(x, i)
290+
# HACK(torfjelde): Julia v1.7 only supports `isassigned(::AbstractArray, ::Int...)`.
291+
# TODO(torfjelde): Determine exactly in which version this change was introduced.
292+
if VERSION < v"v1.9.0-alpha1"
293+
_isassigned(x::AbstractArray, inds::Tuple) = isassigned(x, inds...)
294+
_isassigned(x::AbstractArray, idx::CartesianIndex) = _isassigned(x, Tuple(idx))
295+
end
296+
289297
_has_missings(x) = ismissing(x)
290298
function _has_missings(x::AbstractArray)
291299
# Can't just use `any` because `x` might contain `undef`.
292300
for i in eachindex(x)
293-
if isassigned(x, i) && _has_missings(x[i])
301+
if _isassigned(x, i) && _has_missings(x[i])
294302
return true
295303
end
296304
end

0 commit comments

Comments
 (0)