@@ -25,21 +25,21 @@ ChainRules.rrule(::typeof(my_tuple), args...) = args, Δ->Core.tuple(NoTangent()
25
25
# Check characteristic of exp rule
26
26
@variables ω α β γ δ ϵ ζ η
27
27
(x1, c1) = ∂⃖ {3} ()(exp, ω)
28
- @test simplify (x1 == exp (ω)). val
28
+ @test isequal ( simplify (x1), simplify ( exp (ω)))
29
29
((_, x2), c2) = c1 (α)
30
- @test simplify (x2 == α* exp (ω)). val
30
+ @test isequal ( simplify (x2), simplify ( α* exp (ω)))
31
31
(x3, c3) = c2 (ZeroTangent (), β)
32
- @test simplify (x3 == β* exp (ω)). val
32
+ @test isequal ( simplify (x3), simplify ( β* exp (ω)))
33
33
((_, x4), c4) = c3 (γ)
34
- @test simplify (x4 == exp (ω)* (γ + (α* β))). val
34
+ @test isequal ( simplify (x4), simplify ( exp (ω)* (γ + (α* β))))
35
35
(x5, c5) = c4 (ZeroTangent (), δ)
36
- @test simplify (x5 == δ* exp (ω)). val
36
+ @test isequal ( simplify (x5), simplify ( δ* exp (ω)))
37
37
((_, x6), c6) = c5 (ϵ)
38
- @test simplify (x6 == ϵ* exp (ω) + α* δ* exp (ω)). val
38
+ @test isequal ( simplify (x6), simplify ( ϵ* exp (ω) + α* δ* exp (ω)))
39
39
(x7, c7) = c6 (ZeroTangent (), ζ)
40
- @test simplify (x7 == ζ* exp (ω) + β* δ* exp (ω)). val
40
+ @test isequal ( simplify (x7), simplify ( ζ* exp (ω) + β* δ* exp (ω)))
41
41
(_, x8) = c7 (η)
42
- @test simplify (x8 == ( η + (α* ζ) + (β* ϵ) + (δ* (γ + (α* β))))* exp (ω)). val
42
+ @test isequal ( simplify (x8), simplify (( η + (α* ζ) + (β* ϵ) + (δ* (γ + (α* β))))* exp (ω)))
43
43
44
44
# Minimal 2-nd order forward smoke test
45
45
@test Diffractor.∂☆ {2} ()(Diffractor. ZeroBundle {2} (sin),
@@ -123,10 +123,12 @@ let var"'" = Diffractor.PrimeDerivativeFwd
123
123
# Integration tests
124
124
@test recursive_sin' (1.0 ) == cos (1.0 )
125
125
@test recursive_sin'' (1.0 ) == - sin (1.0 )
126
- @test recursive_sin''' (1.0 ) == - cos (1.0 )
127
- @test recursive_sin'''' (1.0 ) == sin (1.0 )
128
- @test recursive_sin''''' (1.0 ) == cos (1.0 )
129
- @test recursive_sin'''''' (1.0 ) == - sin (1.0 )
126
+ # Error: ArgumentError: Tangent for the primal Tangent{Tuple{Float64, Float64}, Tuple{Float64, Float64}}
127
+ # should be backed by a NamedTuple type, not by Tuple{Tangent{Tuple{Float64, Float64}, Tuple{Float64, Float64}}}.
128
+ @test_broken recursive_sin''' (1.0 ) == - cos (1.0 )
129
+ @test_broken recursive_sin'''' (1.0 ) == sin (1.0 )
130
+ @test_broken recursive_sin''''' (1.0 ) == cos (1.0 )
131
+ @test_broken recursive_sin'''''' (1.0 ) == - sin (1.0 )
130
132
131
133
# Test the special rules for sin/cos/exp
132
134
@test sin'''''' (1.0 ) == - sin (1.0 )
148
150
@test gradient (x -> sum (abs2, x .+ 1.0 ), zeros (3 ))[1 ] == [2.0 , 2.0 , 2.0 ]
149
151
150
152
const fwd = Diffractor. PrimeDerivativeFwd
151
- const bwd = Diffractor. PrimeDerivativeFwd
153
+ const bwd = Diffractor. PrimeDerivativeBack
152
154
153
155
function f_broadcast (a)
154
156
l = a / 2.0 * [[0. 1. 1. ]; [1. 0. 1. ]; [1. 1. 0. ]]
186
188
# Issue #27 - Mixup in lifting of getfield
187
189
let var"'" = bwd
188
190
@test (x-> x^ 5 )'' (1.0 ) == 20.
189
- @test (x-> x^ 5 )''' (1.0 ) == 60.
191
+ @test (x-> (x* x)* (x* x)* x)''' == 60.
192
+ # Higher order control flow not yet supported (https://github.com/JuliaDiff/Diffractor.jl/issues/24)
193
+ @test_broken (x-> x^ 5 )''' (1.0 ) == 60.
190
194
end
191
195
192
196
# Issue #38 - Splatting arrays
0 commit comments