Skip to content

Commit c30bcd9

Browse files
authored
Fix deprecations (#229)
* Fix deprecations * Update test/ad/distributions.jl * Update test/ad/distributions.jl
1 parent 02ca329 commit c30bcd9

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributionsAD"
22
uuid = "ced4e74d-a319-5a8a-b0ac-84af2272839c"
3-
version = "0.6.42"
3+
version = "0.6.43"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ AD of `logpdf` is fully supported and tested for the following distributions wrt
2424
- `Chi`
2525
- `Chisq`
2626
- `Cosine`
27+
- `Distributions.AffineDistribution`
2728
- `Epanechnikov`
2829
- `Erlang`
2930
- `Exponential`
@@ -38,7 +39,6 @@ AD of `logpdf` is fully supported and tested for the following distributions wrt
3839
- `Kolmogorov`
3940
- `Laplace`
4041
- `Levy`
41-
- `LocationScale`
4242
- `Logistic`
4343
- `LogitNormal`
4444
- `LogNormal`

src/common.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
## Linear Algebra ##
22

3+
const CHOLESKY_NoPivot = VERSION >= v"1.8.0-rc1" ? LinearAlgebra.NoPivot() : Val(false)
4+
35
function turing_chol(A::AbstractMatrix, check)
46
chol = cholesky(A, check=check)
57
(chol.factors, chol.info)
68
end
79
function turing_chol_back(A::AbstractMatrix, check)
8-
C, chol_pullback = rrule(cholesky, A, Val(false), check=check)
10+
C, chol_pullback = rrule(cholesky, A, CHOLESKY_NoPivot; check=check)
911
function back(Δ)
1012
= Tangent{typeof(C)}(; factors=Δ[1])
1113
∂C = chol_pullback(Ȳ)[2]
@@ -19,7 +21,7 @@ function symm_turing_chol(A::AbstractMatrix, check, uplo)
1921
(chol.factors, chol.info)
2022
end
2123
function symm_turing_chol_back(A::AbstractMatrix, check, uplo)
22-
C, chol_pullback = rrule(cholesky, Symmetric(A,uplo), Val(false), check=check)
24+
C, chol_pullback = rrule(cholesky, Symmetric(A,uplo), CHOLESKY_NoPivot; check=check)
2325
function back(Δ)
2426
= Tangent{typeof(C)}(; factors=Δ[1])
2527
∂C = chol_pullback(Ȳ)[2]

src/flatten.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const flattened_dists = [ Bernoulli,
4646
Kolmogorov,
4747
Laplace,
4848
Levy,
49-
LocationScale,
49+
Distributions.AffineDistribution,
5050
Logistic,
5151
LogitNormal,
5252
LogNormal,

src/reversediff.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ function Gamma(α::T, θ::T; check_args=true) where {T <: TrackedReal}
148148
end
149149

150150
# Work around to stop TrackedReal of Inf and -Inf from producing NaN in the derivative
151-
function Base.minimum(d::LocationScale{T}) where {T <: TrackedReal}
151+
function Base.minimum(d::Distributions.AffineDistribution{T}) where {T <: TrackedReal}
152152
if isfinite(minimum(d.ρ))
153153
return d.μ + d.σ * minimum(d.ρ)
154154
else
155155
return convert(T, ReverseDiff.@skip(minimum)(d.ρ))
156156
end
157157
end
158-
function Base.maximum(d::LocationScale{T}) where {T <: TrackedReal}
158+
function Base.maximum(d::Distributions.AffineDistribution{T}) where {T <: TrackedReal}
159159
if isfinite(minimum(d.ρ))
160160
return d.μ + d.σ * maximum(d.ρ)
161161
else

test/ad/distributions.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@
143143
DistSpec(Levy, (0.0,), 0.5),
144144
DistSpec(Levy, (0.0, 2.0), 0.5),
145145

146-
DistSpec((a, b) -> LocationScale(a, b, Normal()), (1.0, 2.0), 0.5),
146+
# Test AffineDistribution
147+
DistSpec((a, b) -> a + b * Beta(), (1.0, 2.0), 2.0),
147148

148149
DistSpec(Logistic, (), 0.5),
149150
DistSpec(Logistic, (1.0,), 0.5),

0 commit comments

Comments
 (0)