Skip to content

Commit

Permalink
Fix deprecations in SpecialFunctions.jl (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano authored Mar 13, 2021
1 parent e0625c1 commit d83e542
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
17 changes: 10 additions & 7 deletions src/special-functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ function SpecialFunctions.gamma(a::Measurement)
return result(Γ, Γ*digamma(aval), a)
end

function SpecialFunctions.lgamma(a::Measurement)
function SpecialFunctions.logabsgamma(a::Measurement)
aval = a.val
return result(lgamma(aval), digamma(aval), a)
logabs, s = logabsgamma(a.val)
return (result(logabs, digamma(aval), a), result(s, 0, a))
end

function SpecialFunctions.digamma(a::Measurement)
Expand Down Expand Up @@ -120,13 +121,15 @@ end

SpecialFunctions.beta(a::Real, b::Measurement) = beta(b, a)

function SpecialFunctions.lbeta(a::Measurement, b::Measurement)
function SpecialFunctions.logabsbeta(a::Measurement, b::Measurement)
aval = a.val
bval = b.val
return result(lbeta(aval, bval),
(digamma(aval) - digamma(aval + bval),
digamma(bval) - digamma(aval + bval)),
(a, b))
logabs, s = logabsbeta(a.val, b.val)
return (result(logabs,
(digamma(aval) - digamma(aval + bval),
digamma(bval) - digamma(aval + bval)),
(a, b)),
result(s, (0, 0), (a, b)))
end

function SpecialFunctions.lbeta(a::Measurement, b::Real)
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ end
for a in (w, x, y)
@test @inferred(gamma(a)) factorial(a - one(a))
@test @inferred(gamma(a + one(a))) factorial(a)
@test @inferred(lgamma(abs(a))) log(gamma(abs(a)))
@test @inferred(logabsgamma(abs(a)))[1] log(gamma(abs(a)))
@test @inferred(digamma(a)) polygamma(0, a)
@test @inferred(digamma(invdigamma(a))) a + zero(a)
@test @inferred(trigamma(a)) polygamma(1, a)
Expand All @@ -480,9 +480,9 @@ end
@test beta(a, x) gamma(a)*gamma(x)/gamma(a + x)
@test beta(a, pi) gamma(a)*gamma(pi)/gamma(a + pi)
@test beta(ℯ, a) gamma(ℯ)*gamma(a)/gamma(ℯ + a)
@test lbeta(abs(a), x) log(beta(abs(a), x))
@test lbeta(abs(a), pi) log(beta(abs(a), pi))
@test lbeta(ℯ, abs(a)) log(beta(ℯ, abs(a)))
@test logabsbeta(abs(a), x)[1] log(beta(abs(a), x))
@test logabsbeta(abs(a), pi)[1] log(beta(abs(a), pi))
@test logabsbeta(ℯ, abs(a))[1] log(beta(ℯ, abs(a)))
end
end

Expand Down

0 comments on commit d83e542

Please sign in to comment.