Skip to content

Commit 911cd3d

Browse files
authored
Merge pull request #45 from tpapp/tp/cosmetic-fixes
cosmetic changes
2 parents 1b6461d + ab7a075 commit 911cd3d

File tree

4 files changed

+48
-29
lines changed

4 files changed

+48
-29
lines changed

src/generic.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
export dimension, transform, transform_and_logjac, transform_logdensity, inverse, inverse!,
22
inverse_eltype, as, random_arg, random_value
33

4-
5-
# log absolute Jacobian determinant
4+
####
5+
#### log absolute Jacobian determinant
6+
####
67

78
"""
89
$(TYPEDEF)
@@ -47,8 +48,9 @@ logjac_zero(::LogJac, T::Type{<:Real}) = log(one(T))
4748

4849
logjac_zero(::NoLogJac, _) = NOLOGJAC
4950

50-
51-
# general
51+
####
52+
#### general
53+
####
5254

5355
"""
5456
$(TYPEDEF)
@@ -163,8 +165,9 @@ as((a = asℝ₊, b = as𝕀)) # transform 2 real numbers a NamedTuple, with a >
163165
"""
164166
function as end
165167

166-
167-
# vector transformations
168+
####
169+
#### vector transformations
170+
####
168171

169172
"""
170173
An `AbstractVector` of `<:Real` elements.

src/scalar.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ inverse_eltype(t::ScalarTransform, y::T) where {T <: Real} = float(T)
2626

2727
random_arg(t::ScalarTransform; kwargs...) = random_real(; kwargs...)
2828

29-
30-
# identity
29+
####
30+
#### identity
31+
####
3132

3233
"""
3334
$(TYPEDEF)
@@ -42,8 +43,9 @@ transform_and_logjac(::Identity, x::Real) = x, zero(x)
4243

4344
inverse(::Identity, x::Real) = x
4445

45-
46-
# shifted exponential
46+
####
47+
#### shifted exponential
48+
####
4749

4850
"""
4951
$(TYPEDEF)
@@ -77,8 +79,9 @@ function inverse(t::ShiftedExp{D}, x::Real) where D
7779
end
7880
end
7981

80-
81-
# scaled and shifted logistic
82+
####
83+
#### scaled and shifted logistic
84+
####
8285

8386
"""
8487
$(TYPEDEF)
@@ -123,8 +126,9 @@ function inverse_and_logjac(t::ScaledShiftedLogistic, y)
123126
logit(z), logit_logjac(z) - log(t.scale)
124127
end
125128

126-
127-
# to_interval interface
129+
####
130+
#### to_interval interface
131+
####
128132

129133
struct Infinity{ispositive}
130134
Infinity{T}() where T = (@argcheck T isa Bool; new{T}())

src/special_arrays.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
export UnitVector, CorrCholeskyFactor
22

3+
####
4+
#### building blocks
5+
####
6+
37
"""
48
(y, r, ℓ) = $SIGNATURES
59
@@ -24,7 +28,10 @@ Inverse of [`l2_remainder_transform`](@ref) in `x` and `y`.
2428
"""
2529
@inline l2_remainder_inverse(y, r) = logit((y/√r+1)/2), r-abs2(y)
2630

27-
31+
####
32+
#### UnitVector
33+
####
34+
2835
"""
2936
UnitVector(n)
3037
@@ -74,8 +81,9 @@ function inverse!(x::RealVector, t::UnitVector, y::RealVector)
7481
x
7582
end
7683

77-
78-
# correlation cholesky factor
84+
####
85+
#### correlation cholesky factor
86+
####
7987

8088
"""
8189
CorrCholeskyFactor(n)

test/runtests.jl

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,22 @@ end
6464
end
6565

6666
@testset "to unit vector" begin
67-
U = UnitVector(3)
68-
x = zeros(3) # incorrect
69-
@test_throws ArgumentError U(x)
70-
@test_throws ArgumentError transform(U, x)
71-
@test_throws ArgumentError transform_and_logjac(U, x)
72-
73-
for K in 1:10
74-
t = UnitVector(K)
75-
@test dimension(t) == K - 1
76-
if K > 1
77-
test_transformation(t, y -> sum(abs2, y) 1,
78-
vec_y = y -> y[1:(end-1)])
67+
@testset "dimension checks" begin
68+
U = UnitVector(3)
69+
x = zeros(3) # incorrect
70+
@test_throws ArgumentError U(x)
71+
@test_throws ArgumentError transform(U, x)
72+
@test_throws ArgumentError transform_and_logjac(U, x)
73+
end
74+
75+
@testset "consistency checks" begin
76+
for K in 1:10
77+
t = UnitVector(K)
78+
@test dimension(t) == K - 1
79+
if K > 1
80+
test_transformation(t, y -> sum(abs2, y) 1,
81+
vec_y = y -> y[1:(end-1)])
82+
end
7983
end
8084
end
8185
end

0 commit comments

Comments
 (0)