Skip to content

Commit 1b6461d

Browse files
committed
Merge branch 'master' of github.com:tpapp/TransformVariables.jl
2 parents 3dae7b2 + 5d4906d commit 1b6461d

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/special_arrays.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ dimension(t::CorrCholeskyFactor) = unit_triangular_dimension(t.n)
9797

9898
function transform_with(flag::LogJacFlag, t::CorrCholeskyFactor, x::RealVector)
9999
@unpack n = t
100+
@argcheck length(x) == dimension(t)
100101
T = extended_eltype(x)
101102
= logjac_zero(flag, T)
102103
U = Matrix{T}(undef, n, n)

test/runtests.jl

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,24 @@ end
8181
end
8282

8383
@testset "to correlation cholesky factor" begin
84-
for K in 1:8
85-
t = CorrCholeskyFactor(K)
86-
@test dimension(t) == (K - 1)*K/2
87-
CIENV && @info "testing correlation cholesky K = $(K)"
88-
if K > 1
89-
test_transformation(t, is_valid_corr_cholesky;
90-
vec_y = vec_above_diagonal, N = 100)
84+
@testset "dimension checks" begin
85+
C = CorrCholeskyFactor(3)
86+
wrong_x = zeros(dimension(C) + 1)
87+
88+
@test_throws ArgumentError C(wrong_x)
89+
@test_throws ArgumentError transform(C, wrong_x)
90+
@test_throws ArgumentError transform_and_logjac(C, wrong_x)
91+
end
92+
93+
@testset "consistency checks" begin
94+
for K in 1:8
95+
t = CorrCholeskyFactor(K)
96+
@test dimension(t) == (K - 1)*K/2
97+
CIENV && @info "testing correlation cholesky K = $(K)"
98+
if K > 1
99+
test_transformation(t, is_valid_corr_cholesky;
100+
vec_y = vec_above_diagonal, N = 100)
101+
end
91102
end
92103
end
93104
end

0 commit comments

Comments
 (0)