Skip to content

Commit

Permalink
Fix for check_model on Julia <1.9 (#631)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
torfjelde and yebai authored Jul 15, 2024
1 parent 123d7bf commit dfdc155
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DynamicPPL"
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
version = "0.28"
version = "0.28.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
10 changes: 9 additions & 1 deletion src/debug_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,19 @@ function record_varname!(context::DebugContext, varname::VarName, dist)
end

# tilde
_isassigned(x::AbstractArray, i) = isassigned(x, i)
# HACK(torfjelde): Julia v1.7 only supports `isassigned(::AbstractArray, ::Int...)`.
# TODO(torfjelde): Determine exactly in which version this change was introduced.
if VERSION < v"v1.9.0-alpha1"
_isassigned(x::AbstractArray, inds::Tuple) = isassigned(x, inds...)
_isassigned(x::AbstractArray, idx::CartesianIndex) = _isassigned(x, Tuple(idx))
end

_has_missings(x) = ismissing(x)
function _has_missings(x::AbstractArray)
# Can't just use `any` because `x` might contain `undef`.
for i in eachindex(x)
if isassigned(x, i) && _has_missings(x[i])
if _isassigned(x, i) && _has_missings(x[i])
return true
end
end
Expand Down

2 comments on commit dfdc155

@yebai
Copy link
Member

@yebai yebai commented on dfdc155 Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/111120

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.28.1 -m "<description of version>" dfdc155b191764db53e96a3e52c9a8d0f46e09ac
git push origin v0.28.1

Please sign in to comment.