Skip to content

Commit 60e6855

Browse files
committed
simpler
1 parent bab3793 commit 60e6855

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

test/grad.jl

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,29 +221,22 @@ end
221221
using LinearAlgebra
222222

223223
function partial_nan_returning(x)
224-
y = Matrix{Float64}(undef, 5, 5)
225-
y .= NaN
226-
y = Hermitian(y)
227-
y .= x
228-
return parent(y)
224+
return Float64[NaN, x]
229225
end
230226

231227
randvar = 1
232228
function partial_nondet_returning(x)
233229
global randvar
234-
y = Matrix{Float64}(undef, 5, 5)
235-
y .= randvar
230+
y = Float64[randvar, x]
236231
randvar += 1
237-
y = Hermitian(y)
238-
y .= x
239-
return parent(y)
232+
return y
240233
end
241234

242235
@testset "jvp: Estimate step correctly for when some terms are nan/infinite" begin
243236
fdm = FiniteDifferences.central_fdm(5, 1)
244237
res = jvp(fdm, partial_nan_returning, (3.1, 2.7))
245-
@test all(Hermitian(res) . 2.7)
238+
@test res[1] 2.7
246239

247240
res = jvp(fdm, partial_nondet_returning, (3.1, 2.7))
248-
@test all(Hermitian(res) . 2.7)
241+
@test res[1] 2.7
249242
end

0 commit comments

Comments
 (0)