Skip to content

Commit dd606d7

Browse files
"Update tests"
By removing the option, which is effectively reverting the test changes because now the option is gone and what the tests added was tests that the option worked. Because the tests already have inference testing, even the inference test is unnecessary to keep so we're good.
1 parent 8a67a86 commit dd606d7

File tree

3 files changed

+11
-30
lines changed

3 files changed

+11
-30
lines changed

test/GradientTest.jl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import NaNMath
66
using Test
77
using LinearAlgebra
88
using ForwardDiff
9-
using ForwardDiff: Dual, maketag
9+
using ForwardDiff: Dual, Tag
1010
using StaticArrays
1111
using DiffTests
1212

@@ -21,8 +21,7 @@ x = [0.1, 0.2, 0.3]
2121
v = f(x)
2222
g = [-9.4, 15.6, 52.0]
2323

24-
@testset "Rosenbrock, chunk size = $c and tag = $(repr(maketag(tag, f, eltype(x))))" for c in (1, 2, 3), tag in (nothing, :default, :small)
25-
tag = maketag(tag, f, eltype(x))
24+
@testset "Rosenbrock, chunk size = $c and tag = $(repr(tag))" for c in (1, 2, 3), tag in (nothing, Tag(f, eltype(x)))
2625
cfg = ForwardDiff.GradientConfig(f, x, ForwardDiff.Chunk{c}(), tag)
2726

2827
@test eltype(cfg) == Dual{typeof(tag), eltype(x), c}
@@ -61,8 +60,7 @@ cfgx = ForwardDiff.GradientConfig(sin, x)
6160
v = f(X)
6261
g = ForwardDiff.gradient(f, X)
6362
@test isapprox(g, Calculus.gradient(f, X), atol=FINITEDIFF_ERROR)
64-
@testset "... with chunk size = $c and tag = $(repr(maketag(tag, f, eltype(x))))" for c in CHUNK_SIZES, tag in (nothing, :default, :small)
65-
tag = maketag(tag, f, eltype(x))
63+
@testset "... with chunk size = $c and tag = $(repr(tag))" for c in CHUNK_SIZES, tag in (nothing, Tag(f, eltype(x)))
6664
cfg = ForwardDiff.GradientConfig(f, X, ForwardDiff.Chunk{c}(), tag)
6765

6866
out = ForwardDiff.gradient(f, X, cfg)
@@ -142,12 +140,6 @@ end
142140

143141
# make sure this is not a source of type instability
144142
@inferred ForwardDiff.GradientConfig(f, sx)
145-
if VERSION v"1.11"
146-
# make sure that `GradientConfig(...; tag = compile-time-constant)` also
147-
# infers well (requires that Base.hash(::Type) is foldable, which is true
148-
# in Julia ≥ 1.11)
149-
@inferred ((f, sx)->ForwardDiff.GradientConfig(f, sx; tag=:small))(f, sx)
150-
end
151143
end
152144

153145
@testset "exponential function at base zero" begin

test/HessianTest.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Calculus
55
using Test
66
using LinearAlgebra
77
using ForwardDiff
8-
using ForwardDiff: Dual, maketag
8+
using ForwardDiff: Dual, Tag
99
using StaticArrays
1010
using DiffTests
1111

@@ -23,8 +23,7 @@ h = [-66.0 -40.0 0.0;
2323
-40.0 130.0 -80.0;
2424
0.0 -80.0 200.0]
2525

26-
@testset "running hardcoded test with chunk size = $c and tag = $(repr(maketag(tag, (f, ForwardDiff.gradient), eltype(x))))" for c in HESSIAN_CHUNK_SIZES, tag in (nothing, :default, :small)
27-
tag = maketag(tag, (f, ForwardDiff.gradient), eltype(x))
26+
@testset "running hardcoded test with chunk size = $c and tag = $(repr(tag))" for c in HESSIAN_CHUNK_SIZES, tag in (nothing, Tag((f,ForwardDiff.gradient), eltype(x)))
2827
cfg = ForwardDiff.HessianConfig(f, x, ForwardDiff.Chunk{c}(), tag)
2928
resultcfg = ForwardDiff.HessianConfig(f, DiffResults.HessianResult(x), x, ForwardDiff.Chunk{c}(), tag)
3029

@@ -69,8 +68,7 @@ for f in DiffTests.VECTOR_TO_NUMBER_FUNCS
6968
h = ForwardDiff.hessian(f, X)
7069
# finite difference approximation error is really bad for Hessians...
7170
@test isapprox(h, Calculus.hessian(f, X), atol=0.02)
72-
@testset "$f with chunk size = $c and tag = $(repr(maketag(tag, (f, ForwardDiff.gradient), eltype(x))))" for c in HESSIAN_CHUNK_SIZES, tag in (nothing, :default, :small)
73-
tag = maketag(tag, (f, ForwardDiff.gradient), eltype(x))
71+
@testset "$f with chunk size = $c and tag = $(repr(tag))" for c in HESSIAN_CHUNK_SIZES, tag in (nothing, Tag((f,ForwardDiff.gradient), eltype(x)))
7472
cfg = ForwardDiff.HessianConfig(f, X, ForwardDiff.Chunk{c}(), tag)
7573
resultcfg = ForwardDiff.HessianConfig(f, DiffResults.HessianResult(X), X, ForwardDiff.Chunk{c}(), tag)
7674

test/JacobianTest.jl

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Calculus
44

55
using Test
66
using ForwardDiff
7-
using ForwardDiff: Dual, Tag, HashTag, JacobianConfig, maketag
7+
using ForwardDiff: Dual, Tag, JacobianConfig
88
using StaticArrays
99
using DiffTests
1010
using LinearAlgebra
@@ -31,8 +31,8 @@ j = [0.8242369704835132 0.4121184852417566 -10.933563142616123
3131
0.169076696546684 0.084538348273342 -2.299173530851733
3232
0.0 0.0 1.0]
3333

34-
for c in (1, 2, 3), tag in (nothing, :small, :default)
35-
tags = (maketag(tag, f, eltype(x)), maketag(tag, f!, eltype(x)))
34+
for c in (1, 2, 3), tags in ((nothing, nothing),
35+
(Tag(f, eltype(x)), Tag(f!, eltype(x))))
3636
println(" ...running hardcoded test with chunk size = $c and tag = $(repr(tags))")
3737
cfg = JacobianConfig(f, x, ForwardDiff.Chunk{c}(), tags[1])
3838
ycfg = JacobianConfig(f!, fill(0.0, 4), x, ForwardDiff.Chunk{c}(), tags[2])
@@ -103,11 +103,9 @@ for f in DiffTests.ARRAY_TO_ARRAY_FUNCS
103103
v = f(X)
104104
j = ForwardDiff.jacobian(f, X)
105105
@test isapprox(j, Calculus.jacobian(x -> vec(f(x)), X, :forward), atol=1.3FINITEDIFF_ERROR)
106-
@testset "$f with chunk size = $c and tag = $(repr(tag))" for c in CHUNK_SIZES, tag in (nothing, Tag, HashTag)
106+
@testset "$f with chunk size = $c and tag = $(repr(tag))" for c in CHUNK_SIZES, tag in (nothing, Tag)
107107
if tag == Tag
108108
tag = Tag(f, eltype(X))
109-
elseif tag == HashTag
110-
tag = HashTag(f, eltype(X))
111109
end
112110
cfg = JacobianConfig(f, X, ForwardDiff.Chunk{c}(), tag)
113111

@@ -130,8 +128,7 @@ for f! in DiffTests.INPLACE_ARRAY_TO_ARRAY_FUNCS
130128
f!(v, X)
131129
j = ForwardDiff.jacobian(f!, fill!(similar(Y), 0.0), X)
132130
@test isapprox(j, Calculus.jacobian(x -> (y = fill!(similar(Y), 0.0); f!(y, x); vec(y)), X, :forward), atol=FINITEDIFF_ERROR)
133-
@testset "$(f!) with chunk size = $c and tag = $(repr(maketag(tag, f!, eltype(X))))" for c in CHUNK_SIZES, tag in (nothing, :small, :default)
134-
tag = maketag(tag, f!, eltype(X))
131+
@testset "$(f!) with chunk size = $c and tag = $(repr(tag))" for c in CHUNK_SIZES, tag in (nothing, Tag(f!, eltype(X)))
135132
ycfg = JacobianConfig(f!, fill!(similar(Y), 0.0), X, ForwardDiff.Chunk{c}(), tag)
136133

137134
y = fill!(similar(Y), 0.0)
@@ -228,12 +225,6 @@ for T in (StaticArrays.SArray, StaticArrays.MArray)
228225

229226
# make sure this is not a source of type instability
230227
@inferred ForwardDiff.JacobianConfig(f, sx)
231-
if VERSION v"1.11"
232-
# make sure that `JacobianConfig(...; tag = compile-time-constant)` also
233-
# infers well (requires that Base.hash(::Type) is foldable, which is true
234-
# in Julia ≥ 1.11)
235-
@inferred ((f, sx)->ForwardDiff.JacobianConfig(f, sx; tag=:small))(f, sx)
236-
end
237228
end
238229

239230
#########

0 commit comments

Comments
 (0)