@@ -24,6 +24,11 @@ using FiniteDifferences: rand_tangent
24
24
(randn (Complex{Float32}, 5 , 4 ), Matrix{Complex{Float32}}),
25
25
([randn (5 , 4 ), 4.0 ], Vector{Any}),
26
26
27
+ # Wrapper Arrays
28
+ (randn (5 , 4 )' , Adjoint{Float64, Matrix{Float64}}),
29
+ (transpose (randn (5 , 4 )), Transpose{Float64, Matrix{Float64}}),
30
+
31
+
27
32
# Tuples.
28
33
((4.0 , ), Tangent{Tuple{Float64}}),
29
34
((5.0 , randn (3 )), Tangent{Tuple{Float64, Vector{Float64}}}),
@@ -66,20 +71,19 @@ using FiniteDifferences: rand_tangent
66
71
Hermitian (randn (ComplexF64, 1 , 1 )),
67
72
Tangent{Hermitian{ComplexF64, Matrix{ComplexF64}}},
68
73
),
69
- (
70
- Adjoint (randn (ComplexF64, 3 , 3 )),
71
- Tangent{Adjoint{ComplexF64, Matrix{ComplexF64}}},
72
- ),
73
- (
74
- Transpose (randn (3 )),
75
- Tangent{Transpose{Float64, Vector{Float64}}},
76
- ),
77
74
]
78
75
@test rand_tangent (rng, x) isa T_tangent
79
76
@test rand_tangent (x) isa T_tangent
80
- @test x + rand_tangent (rng, x) isa typeof (x)
81
77
end
82
78
83
- # Ensure struct fallback errors for non-struct types.
84
- @test_throws ArgumentError invoke (rand_tangent, Tuple{AbstractRNG, Any}, rng, 5.0 )
79
+ @testset " erroring cases" begin
80
+ # Ensure struct fallback errors for non-struct types.
81
+ @test_throws ArgumentError invoke (rand_tangent, Tuple{AbstractRNG, Any}, rng, 5.0 )
82
+ end
83
+
84
+ @testset " compsition of addition" begin
85
+ x = Foo (1.5 , 2 , Foo (1.1 , 3 , [1.7 , 1.4 , 0.9 ]))
86
+ @test x + rand_tangent (x) isa typeof (x)
87
+ @test x + (rand_tangent (x) + rand_tangent (x)) isa typeof (x)
88
+ end
85
89
end
0 commit comments