@@ -15,6 +15,8 @@ include(joinpath(dirname(@__FILE__), "utils.jl"))
1515# hardcoded test #
1616# #################
1717
18+ @testset " hardcoded" begin
19+
1820f! = (y, x) -> begin
1921 y[1 ] = x[1 ] * x[2 ]
2022 y[1 ] *= sin (x[3 ]^ 2 )
@@ -31,9 +33,8 @@ j = [0.8242369704835132 0.4121184852417566 -10.933563142616123
3133 0.169076696546684 0.084538348273342 - 2.299173530851733
3234 0.0 0.0 1.0 ]
3335
34- for c in (1 , 2 , 3 ), tags in ((nothing , nothing ),
36+ @testset " chunk size = $c and tag = $( repr (tags)) " for c in (1 , 2 , 3 ), tags in ((nothing , nothing ),
3537 (Tag (f, eltype (x)), Tag (f!, eltype (x))))
36- println (" ...running hardcoded test with chunk size = $c and tag = $(repr (tags)) " )
3738 cfg = JacobianConfig (f, x, ForwardDiff. Chunk {c} (), tags[1 ])
3839 ycfg = JacobianConfig (f!, fill (0.0 , 4 ), x, ForwardDiff. Chunk {c} (), tags[2 ])
3940
@@ -95,19 +96,20 @@ cfgx = ForwardDiff.JacobianConfig(sin, x)
9596@test_throws ForwardDiff. InvalidTagException ForwardDiff. jacobian (f, x, cfgx)
9697@test ForwardDiff. jacobian (f, x, cfgx, Val {false} ()) == ForwardDiff. jacobian (f,x)
9798
99+ end
100+
98101# #######################
99102# test vs. Calculus.jl #
100103# #######################
101104
102- for f in DiffTests. ARRAY_TO_ARRAY_FUNCS
105+ @testset " Comparison vs Calculus.jl" begin
106+
107+ @testset " $f " for f in DiffTests. ARRAY_TO_ARRAY_FUNCS
103108 v = f (X)
104109 j = ForwardDiff. jacobian (f, X)
105110 @test isapprox (j, Calculus. jacobian (x -> vec (f (x)), X, :forward ), atol= 1.3 FINITEDIFF_ERROR)
106- for c in CHUNK_SIZES, tag in (nothing , Tag)
107- if tag == Tag
108- tag = Tag (f, eltype (X))
109- end
110- println (" ...testing $f with chunk size = $c and tag = $(repr (tag)) " )
111+
112+ @testset " chunk size = $c and tag = $(repr (tag)) " for c in CHUNK_SIZES, tag in (nothing , Tag (f, eltype (X)))
111113 cfg = JacobianConfig (f, X, ForwardDiff. Chunk {c} (), tag)
112114
113115 out = ForwardDiff. jacobian (f, X, cfg)
@@ -124,13 +126,13 @@ for f in DiffTests.ARRAY_TO_ARRAY_FUNCS
124126 end
125127end
126128
127- for f! in DiffTests. INPLACE_ARRAY_TO_ARRAY_FUNCS
129+ @testset " $f! " for f! in DiffTests. INPLACE_ARRAY_TO_ARRAY_FUNCS
128130 v = fill! (similar (Y), 0.0 )
129131 f! (v, X)
130132 j = ForwardDiff. jacobian (f!, fill! (similar (Y), 0.0 ), X)
131133 @test isapprox (j, Calculus. jacobian (x -> (y = fill! (similar (Y), 0.0 ); f! (y, x); vec (y)), X, :forward ), atol= FINITEDIFF_ERROR)
132- for c in CHUNK_SIZES, tag in ( nothing , Tag (f!, eltype (X)))
133- println ( " ...testing $(f!) with chunk size = $c and tag = $(repr (tag)) " )
134+
135+ @testset " chunk size = $c and tag = $(repr (tag)) " for c in CHUNK_SIZES, tag in ( nothing , Tag (f!, eltype (X)) )
134136 ycfg = JacobianConfig (f!, fill! (similar (Y), 0.0 ), X, ForwardDiff. Chunk {c} (), tag)
135137
136138 y = fill! (similar (Y), 0.0 )
@@ -160,14 +162,14 @@ for f! in DiffTests.INPLACE_ARRAY_TO_ARRAY_FUNCS
160162 end
161163end
162164
165+ end
166+
163167# #########################################
164168# test specialized StaticArray codepaths #
165169# #########################################
166170
167- println (" ...testing specialized StaticArray codepaths" )
168-
169171x = rand (3 , 3 )
170- for T in (StaticArrays. SArray, StaticArrays. MArray)
172+ @testset " Specialized $T codepaths " for T in (StaticArrays. SArray, StaticArrays. MArray)
171173 sx = T {Tuple{3,3}} (x)
172174
173175 cfg = ForwardDiff. JacobianConfig (nothing , x)
0 commit comments