Skip to content

Commit 199cac4

Browse files
committed
add extra second order test
1 parent 9bb17c6 commit 199cac4

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

β€Žtest/forward_mutation.jl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222
@test πŸ₯―[TaylorTangentIndex(2)].x == 10.0
2323
end
2424

25-
@testset "basis struct work" begin
25+
@testset "basis struct work: double" begin
2626
function double!(val::MDemo1)
2727
val.x *= 2.0
2828
return val
@@ -44,6 +44,27 @@ end
4444
@test πŸ‡[TaylorTangentIndex(2)].x == 0.0 # returns 20
4545
end
4646

47+
@testset "basis struct work: square" begin
48+
function square!(val::MDemo1)
49+
val.x ^= 2.0
50+
return val
51+
end
52+
function wrap_and_square(x)
53+
val = MDemo1(x)
54+
square!(val)
55+
end
56+
# first derivative
57+
🐰 = βˆ‚β˜†{1}()(ZeroBundle{1}(wrap_and_square), TaylorBundle{1}(10.0, (1.0,)))
58+
@test first_partial(🐰) isa MutableTangent{MDemo1}
59+
@test first_partial(🐰).x == 20.0
60+
61+
# second derivative
62+
πŸ‡ = βˆ‚β˜†{2}()(ZeroBundle{2}(wrap_and_square), TaylorBundle{2}(1, (1.0, 0.0)))
63+
@test πŸ‡[TaylorTangentIndex(1)] isa MutableTangent{MDemo1}
64+
@test πŸ‡[TaylorTangentIndex(1)].x == 20.0
65+
@test πŸ‡[TaylorTangentIndex(2)] isa MutableTangent
66+
@test πŸ‡[TaylorTangentIndex(2)].x == 2.0 # returns 20
67+
end
4768

4869

4970
# end # module

0 commit comments

Comments
Β (0)