Skip to content

Commit a8647d4

Browse files
authored
Revert "Tighten up a bunch of test accurasy requirements now that have FiniteDifferences v0.11.4 (#315)"
This reverts commit d8eea76.
1 parent d8eea76 commit a8647d4

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1616
ChainRulesCore = "0.9.16"
1717
ChainRulesTestUtils = "0.5"
1818
Compat = "3"
19-
FiniteDifferences = "0.11.4"
19+
FiniteDifferences = "0.11"
2020
Reexport = "0.2"
2121
Requires = "0.5.2, 1"
2222
julia = "1"

test/rulesets/Base/fastmath_able.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ end
4141
# Do not add any tests here for functions that do not have varients in Base.FastMath
4242
# e.g. do not add `foo` unless `Base.FastMath.foo_fast` exists.
4343
const FASTABLE_AST = quote
44+
is_fastmath_mode = sin === Base.FastMath.sin_fast
45+
4446
@testset "Trig" begin
4547
@testset "Basics" for x = (Float64(π)-0.01, Complex(π, π/2))
4648
test_scalar(sin, x)
@@ -104,7 +106,7 @@ const FASTABLE_AST = quote
104106
complex_jacobian_test(angle, z)
105107
end
106108
@test frule((Zero(), randn()), angle, randn())[2] === Zero()
107-
@test rrule(angle, randn())[2](randn())[2] === Zero()
109+
@test rrule(angle, randn())[2](randn())[2] === Zero()
108110

109111
# test that real primal with complex tangent gives complex tangent
110112
ΔΩ = randn(ComplexF64)
@@ -120,7 +122,7 @@ const FASTABLE_AST = quote
120122
for x in (-4.1, 6.4, 0.0, 0.0 + 0.0im, 0.5 + 0.25im)
121123
test_scalar(+, x)
122124
test_scalar(-, x)
123-
test_scalar(atan, x)
125+
test_scalar(atan, x; rtol=(is_fastmath_mode ? 1e-7 : 1e-9))
124126
end
125127
end
126128

@@ -139,8 +141,9 @@ const FASTABLE_AST = quote
139141
y, Δy, ȳ = rand(T, 3)
140142
Δz = randn(typeof(f(x, y)))
141143

142-
frule_test(f, (x, Δx), (y, Δy))
143-
rrule_test(f, Δz, (x, x̄), (y, ȳ))
144+
# some tests struggle in fast_math mode to get accurasy so we relax it some.
145+
frule_test(f, (x, Δx), (y, Δy); rtol=(is_fastmath_mode ? 1e-5 : 1e-7))
146+
rrule_test(f, Δz, (x, x̄), (y, ȳ); rtol=(is_fastmath_mode ? 1e-5 : 1e-7))
144147
end
145148

146149
@testset "$f(x::$T, y::$T) type check" for f in (/, +, -,\, hypot, ^), T in (Float32, Float64)

test/rulesets/LinearAlgebra/blas.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
n = 10
3434
x, ẋ, x̄ = randn(T, n), randn(T, n), randn(T, n)
3535
frule_test(BLAS.nrm2, (x, ẋ))
36-
rrule_test(BLAS.nrm2, randn(), (x, x̄))
36+
rrule_test(BLAS.nrm2, randn(), (x, x̄); rtol=1e-7)
3737
end
3838
end
3939

test/rulesets/LinearAlgebra/factorization.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ using ChainRules: level2partition, level3partition, chol_blocked_rev, chol_unblo
9292
ΔF = unthunk(dF)
9393
_, dX = dX_pullback(ΔF)
9494
X̄_ad = dot(unthunk(dX), V)
95-
X̄_fd = _fdm(0.0) do ε
95+
X̄_fd = central_fdm(5, 1)(0.000_001) do ε
9696
dot(Ȳ, getproperty(cholesky(X .+ ε .* V), p))
9797
end
98-
@test X̄_ad X̄_fd rtol=1e-6 atol=1e-6
98+
@test X̄_ad X̄_fd rtol=1e-4
9999
end
100100
end
101101
@testset "helper functions" begin

0 commit comments

Comments
 (0)