|
1 | 1 | module forward_tests
|
2 | 2 | using Diffractor
|
3 |
| -using Diffractor: var"'", ∂⃖, DiffractorRuleConfig, ZeroBundle |
| 3 | +using Diffractor: TaylorBundle |
4 | 4 | using ChainRules
|
5 | 5 | using ChainRulesCore
|
6 | 6 | using ChainRulesCore: ZeroTangent, NoTangent, frule_via_ad, rrule_via_ad
|
7 | 7 | using LinearAlgebra
|
8 |
| - |
9 | 8 | using Test
|
10 | 9 |
|
11 |
| -const fwd = Diffractor.PrimeDerivativeFwd |
12 |
| -const bwd = Diffractor.PrimeDerivativeBack |
13 |
| - |
14 | 10 |
|
15 | 11 |
|
16 | 12 | # Minimal 2-nd order forward smoke test
|
|
131 | 127 | end
|
132 | 128 | end
|
133 | 129 |
|
| 130 | + |
| 131 | +@testset "taylor_compatible" begin |
| 132 | + taylor_compatible = Diffractor.taylor_compatible |
| 133 | + |
| 134 | + @test taylor_compatible( |
| 135 | + TaylorBundle{1}(10.0, (20.0,)), |
| 136 | + TaylorBundle{1}(20.0, (30.0,)) |
| 137 | + ) |
| 138 | + @test !taylor_compatible( |
| 139 | + TaylorBundle{1}(10.0, (20.0,)), |
| 140 | + TaylorBundle{1}(21.0, (30.0,)) |
| 141 | + ) |
| 142 | + @test taylor_compatible( |
| 143 | + TaylorBundle{2}(10.0, (20.0, 30.)), |
| 144 | + TaylorBundle{2}(20.0, (30.0, 40.)) |
| 145 | + ) |
| 146 | + @test !taylor_compatible( |
| 147 | + TaylorBundle{2}(10.0, (20.0, 30.0)), |
| 148 | + TaylorBundle{2}(20.0, (31.0, 40.0)) |
| 149 | + ) |
| 150 | + |
| 151 | + |
| 152 | + tuptan(args...) = Tangent{typeof(args)}(args...) |
| 153 | + @test taylor_compatible( |
| 154 | + TaylorBundle{1}((10.0, 20.0), (tuptan(20.0, 30.0),)), |
| 155 | + ) |
| 156 | + @test taylor_compatible( |
| 157 | + TaylorBundle{2}((10.0, 20.0), (tuptan(20.0, 30.0),tuptan(30.0, 40.0))), |
| 158 | + ) |
| 159 | + @test !taylor_compatible( |
| 160 | + TaylorBundle{1}((10.0, 20.0), (tuptan(21.0, 30.0),)), |
| 161 | + ) |
| 162 | + @test !taylor_compatible( |
| 163 | + TaylorBundle{2}((10.0, 20.0), (tuptan(20.0, 31.0),tuptan(30.0, 40.0))), |
| 164 | + ) |
| 165 | +end |
| 166 | + |
134 | 167 | end
|
0 commit comments