Skip to content

Commit c9cd701

Browse files
committed
Use ForwardDiff 1.0.1, fix LKJCholesky Jacobian test
1 parent c6facf9 commit c9cd701

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Distributions = "0.25.33"
5151
DistributionsAD = "0.6"
5252
DocStringExtensions = "0.9"
5353
EnzymeCore = "0.8.4"
54-
ForwardDiff = "0.10, 1"
54+
ForwardDiff = "0.10, 1.0.1"
5555
Functors = "0.1, 0.2, 0.3, 0.4, 0.5"
5656
InverseFunctions = "0.1"
5757
IrrationalConstants = "0.1, 0.2"

test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Enzyme = "0.13.12"
3636
EnzymeTestUtils = "0.2.1"
3737
FillArrays = "1"
3838
FiniteDifferences = "0.11, 0.12"
39-
ForwardDiff = "1"
39+
ForwardDiff = "1.0.1"
4040
Functors = "0.1, 0.2, 0.3, 0.4, 0.5"
4141
InverseFunctions = "0.1"
4242
LazyArrays = "1, 2"

test/transform.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,13 @@ end
238238
@testset "uplo: $uplo" for uplo in [:L, :U]
239239
dist = LKJCholesky(3, 1, uplo)
240240
single_sample_tests(dist)
241-
242241
x = rand(dist)
243-
244-
inds = [
245-
LinearIndices(size(x))[I] for I in CartesianIndices(size(x)) if
246-
(uplo === :L && I[2] < I[1]) || (uplo === :U && I[2] > I[1])
247-
]
248242
J = ForwardDiff.jacobian(z -> link(dist, Cholesky(z, x.uplo, x.info)), x.UL)
243+
# Remove columns of Jacobian that are all zero. Due to changes in ForwardDiff
244+
# between 0.10 and 1.0, this is necessary as the exact indices will differ
245+
inds = filter(i -> !all(iszero, J[:, i]), 1:size(J, 2))
249246
J = J[:, inds]
250-
logpdf_turing = logpdf_with_trans(dist, x, true)
251-
@test logpdf(dist, x) - _logabsdet(J) logpdf_turing
247+
@test logpdf(dist, x) - _logabsdet(J) logpdf_with_trans(dist, x, true)
252248
end
253249
end
254250

0 commit comments

Comments
 (0)