Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions test/DualTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,19 @@ ForwardDiff.:≺(::Type{OuterTestTag}, ::Type{TestTag}) = false
# We have to adjust tolerances if lower accuracy is requested
# Therefore we don't use `dual_isapprox`
tol = V === Float32 ? 5f-4 : 1e-5
tol = tol^(one(tol) / 2^(isempty(ind) ? 0 : first(ind)))
tolval = tol^(one(tol) / 2^(isempty(ind) ? 0 : first(ind)))
for i in 1:2
@test value(pq[i]) ≈ gamma_inc(a, 1 + PRIMAL, ind...)[i] rtol=tol
@test partials(pq[i]) ≈ PARTIALS * Calculus.derivative(x -> gamma_inc(a, x, ind...)[i], 1 + PRIMAL) rtol=tol
@test value(pq[i]) ≈ gamma_inc(a, 1 + PRIMAL, ind...)[i] rtol=tolval
# ForwardDiff computes the analytic derivative (independent of
# `ind`), so compare against a finite difference of the
# full-accuracy (`ind = 0`) Float64 evaluation: differencing the
# reduced-accuracy `ind` variants (or the V-precision function for
# V === Float32) puts the reference's own error at or above `tol`,
# which makes this test flake for random `a`/`PRIMAL`.
# Float64(1 + PRIMAL) keeps the evaluation point exactly the
# primal of `fdnum` (convert after the V-precision addition).
der = Calculus.derivative(x -> gamma_inc(Float64(a), x, 0)[i], Float64(1 + PRIMAL))
@test partials(pq[i]) ≈ PARTIALS * der rtol=tol
end
end
end
Expand Down
Loading