Skip to content

Commit ede7f84

Browse files
committed
fix 2nd order test
1 parent cf705ed commit ede7f84

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

β€Žtest/forward_mutation.jl

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

25-
function double!(val::MDemo1)
26-
val.x *= 2.0
27-
return val
25+
@testset "basis struct work" begin
26+
function double!(val::MDemo1)
27+
val.x *= 2.0
28+
return val
29+
end
30+
function wrap_and_double(x)
31+
val = MDemo1(x)
32+
double!(val)
33+
end
34+
# first derivative
35+
🐰 = βˆ‚β˜†{1}()(ZeroBundle{1}(wrap_and_double), TaylorBundle{1}(1.5, (1.0,)))
36+
@test first_partial(🐰) isa MutableTangent{MDemo1}
37+
@test first_partial(🐰).x == 2.0
38+
39+
# second derivative
40+
πŸ‡ = βˆ‚β˜†{2}()(ZeroBundle{2}(wrap_and_double), TaylorBundle{2}(1.5, (1.0, 0.0)))
41+
@test πŸ‡[TaylorTangentIndex(1)] isa MutableTangent{MDemo1}
42+
@test πŸ‡[TaylorTangentIndex(1)].x == 2.0
43+
@test πŸ‡[TaylorTangentIndex(2)] isa MutableTangent
44+
@test πŸ‡[TaylorTangentIndex(2)].x == 0.0 # returns 20
2845
end
29-
function wrap_and_double(x)
30-
val = MDemo1(x)
31-
double!(val)
32-
end
33-
🐰 = βˆ‚β˜†{1}()(ZeroBundle{1}(wrap_and_double), TaylorBundle{1}(1.5, (1.0,)))
34-
@test first_partial(🐰) isa MutableTangent{MDemo1}
35-
@test first_partial(🐰).x == 2.0
36-
37-
# second derivative
38-
πŸ‡ = βˆ‚β˜†{2}()(ZeroBundle{2}(wrap_and_double), TaylorBundle{2}(1.5, (1.0, 10.0)))
39-
@test πŸ‡[TaylorTangentIndex(1)] isa MutableTangent{MDemo1}
40-
@test πŸ‡[TaylorTangentIndex(1)].x == 2.0
41-
@test πŸ‡[TaylorTangentIndex(2)] isa MutableTangent
42-
@test πŸ‡[TaylorTangentIndex(2)] == 0.0 # returns 20
43-
4446

4547

46-
foo(val) = val^2
47-
πŸ₯– = βˆ‚β˜†{2}()(ZeroBundle{2}(foo), TaylorBundle{2}(1.0, (0.0, 10.0)))
48-
πŸ₯–[TaylorTangentIndex(1)] # returns 0
49-
πŸ₯–[TaylorTangentIndex(2)] # returns 20
5048

5149
# end # module

0 commit comments

Comments
Β (0)