Skip to content

Commit

Permalink
Fix infinite recursion in CorrBijector/VecCorrBijector (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
penelopeysm authored Nov 30, 2024
1 parent 55501ae commit f52a9c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Bijectors"
uuid = "76274a88-744f-5084-9051-94815aaf08c4"
version = "0.15.1"
version = "0.15.2"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand Down
12 changes: 6 additions & 6 deletions src/bijectors/corr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ struct CorrBijector <: Bijector end

with_logabsdet_jacobian(b::CorrBijector, x) = transform(b, x), logabsdetjac(b, x)

function transform(b::CorrBijector, X::AbstractMatrix{<:Real})
function transform(b::CorrBijector, X)
w = cholesky_upper(X)
r = _link_chol_lkj(w)
return r
end

function with_logabsdet_jacobian(ib::Inverse{CorrBijector}, y::AbstractMatrix{<:Real})
function with_logabsdet_jacobian(ib::Inverse{CorrBijector}, y)
U, logJ = _inv_link_chol_lkj(y)
K = size(U, 1)
for j in 2:(K - 1)
Expand All @@ -80,8 +80,8 @@ function with_logabsdet_jacobian(ib::Inverse{CorrBijector}, y::AbstractMatrix{<:
return pd_from_upper(U), logJ
end

logabsdetjac(::Inverse{CorrBijector}, Y::AbstractMatrix{<:Real}) = _logabsdetjac_inv_corr(Y)
function logabsdetjac(b::CorrBijector, X::AbstractMatrix{<:Real})
logabsdetjac(::Inverse{CorrBijector}, Y) = _logabsdetjac_inv_corr(Y)
function logabsdetjac(b::CorrBijector, X)
#=
It may be more efficient if we can use un-contraint value to prevent call of b
It's recommended to directly call
Expand Down Expand Up @@ -135,7 +135,7 @@ function logabsdetjac(b::VecCorrBijector, x)
return -logabsdetjac(inverse(b), b(x))
end

function with_logabsdet_jacobian(::Inverse{VecCorrBijector}, y::AbstractVector{<:Real})
function with_logabsdet_jacobian(::Inverse{VecCorrBijector}, y)
U_logJ = _inv_link_chol_lkj(y)
# workaround for `Tracker.TrackedTuple` not supporting iteration
U, logJ = U_logJ[1], U_logJ[2]
Expand All @@ -146,7 +146,7 @@ function with_logabsdet_jacobian(::Inverse{VecCorrBijector}, y::AbstractVector{<
return pd_from_upper(U), logJ
end

function logabsdetjac(::Inverse{VecCorrBijector}, y::AbstractVector{<:Real})
function logabsdetjac(::Inverse{VecCorrBijector}, y)
return _logabsdetjac_inv_corr(y)
end

Expand Down

2 comments on commit f52a9c5

@penelopeysm
Copy link
Member Author

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/120443

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.15.2 -m "<description of version>" f52a9c52ede1f43155239447601387eb1dafe394
git push origin v0.15.2

Please sign in to comment.