|
82 | 82 |
|
83 | 83 |
|
84 | 84 | @testset "Refine Differential" begin
|
85 |
| - @test refine_differential(typeof(1.0 + 1im), Wirtinger(2,2)) == Wirtinger(2,2) |
86 |
| - @test refine_differential(typeof([1.0 + 1im]), Wirtinger(2,2)) == Wirtinger(2,2) |
| 85 | + for (p, c) in ( |
| 86 | + (2, -3), |
| 87 | + (2.0 + im, 5.0 - 3.0im), |
| 88 | + ([1+im, 2-im], [-3+im, 4+im]), |
| 89 | + (@thunk(1+2), @thunk(4-3)), |
| 90 | + ) |
| 91 | + w = Wirtinger(p, c) |
| 92 | + @testset "$w" begin |
| 93 | + @test refine_differential(typeof(1.0 + 1im), w) === w |
| 94 | + @test refine_differential(typeof([1.0 + 1im]), w) === w |
87 | 95 |
|
88 |
| - @test refine_differential(typeof(1.2), Wirtinger(2,2)) == 4 |
89 |
| - @test refine_differential(typeof([1.2]), Wirtinger(2,2)) == 4 |
| 96 | + @test refine_differential(typeof(1.2), w) == p + c |
| 97 | + @test refine_differential(typeof([1.2]), w) == p + c |
| 98 | + end |
| 99 | + |
| 100 | + g = ComplexGradient(c) |
| 101 | + @testset "$g" begin |
| 102 | + @test refine_differential(typeof(1.0 + 1im), g) === g |
| 103 | + @test refine_differential(typeof([1.0 + 1im]), g) === g |
| 104 | + |
| 105 | + c isa Thunk && continue |
| 106 | + @test refine_differential(typeof(1.2), g) == real(c) |
| 107 | + @test refine_differential(typeof([1.2]), g) == real(c) |
| 108 | + end |
| 109 | + end |
90 | 110 |
|
91 | 111 | # For most differentials, in most domains, this does nothing
|
92 | 112 | for der in (DNE(), @thunk(23), [1 2], One(), Zero(), 0.0)
|
|
0 commit comments