@@ -115,9 +115,11 @@ a = fill(1.0, N)
115115jac0 = reshape (vcat ([[fill (0.0 , N* (i- 1 )); a; fill (0.0 , N^ 2 - N* i)] for i = 1 : N]. .. ), N^ 2 , N)
116116
117117for op in (:.- , :.+ , :./ , :.* )
118- f = @eval x -> [$ op (x[1 ], a); $ op (x[2 ], a); $ op (x[3 ], a); $ op (x[4 ], a)]
119- jac = @eval ForwardDiff. jacobian (f, a)
120- @test isapprox (jac0, jac)
118+ @eval begin
119+ f = x -> [$ op (x[1 ], a); $ op (x[2 ], a); $ op (x[3 ], a); $ op (x[4 ], a)]
120+ jac = ForwardDiff. jacobian (f, a)
121+ @test isapprox (jac0, jac)
122+ end
121123end
122124
123125# NaNs #
@@ -133,8 +135,10 @@ h = ForwardDiff.hessian(y -> sum(hypot.(x, y)), y)
133135@test h[1 , 1 ] ≈ (x[1 ]^ 2 ) / (x[1 ]^ 2 + y[1 ]^ 2 )^ (3 / 2 )
134136@test h[2 , 2 ] ≈ (x[2 ]^ 2 ) / (x[2 ]^ 2 + y[2 ]^ 2 )^ (3 / 2 )
135137@test h[3 , 3 ] ≈ (x[3 ]^ 2 ) / (x[3 ]^ 2 + y[3 ]^ 2 )^ (3 / 2 )
136- for i in 1 : 3 , j in 1 : 3
137- i != j && (@test h[i, j] ≈ 0.0 )
138+ let i, j
139+ for i in 1 : 3 , j in 1 : 3
140+ i != j && @test h[i, j] ≈ 0.0
141+ end
138142end
139143
140144# #######
144148# issue 267
145149@noinline f267 (z, x) = x[1 ]
146150z267 = ([(1 , (2 ), [(3 , (4 , 5 , [1 , 2 , (3 , (4 , 5 ), [5 ])]), (5 ))])])
147- let z = z267
148- g = x -> f267 (z, x)
151+ let z = z267,
152+ g = x -> f267 (z, x),
149153 h = x -> g (x)
150154 @test ForwardDiff. hessian (h, [1. ]) == fill (0.0 , 1 , 1 )
151155end
0 commit comments