@@ -24,6 +24,11 @@ using FiniteDifferences: rand_tangent
2424 (randn (Complex{Float32}, 5 , 4 ), Matrix{Complex{Float32}}),
2525 ([randn (5 , 4 ), 4.0 ], Vector{Any}),
2626
27+ # Wrapper Arrays
28+ (randn (5 , 4 )' , Adjoint{Float64, Matrix{Float64}}),
29+ (transpose (randn (5 , 4 )), Transpose{Float64, Matrix{Float64}}),
30+
31+
2732 # Tuples.
2833 ((4.0 , ), Tangent{Tuple{Float64}}),
2934 ((5.0 , randn (3 )), Tangent{Tuple{Float64, Vector{Float64}}}),
@@ -66,20 +71,19 @@ using FiniteDifferences: rand_tangent
6671 Hermitian (randn (ComplexF64, 1 , 1 )),
6772 Tangent{Hermitian{ComplexF64, Matrix{ComplexF64}}},
6873 ),
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- ),
7774 ]
7875 @test rand_tangent (rng, x) isa T_tangent
7976 @test rand_tangent (x) isa T_tangent
80- @test x + rand_tangent (rng, x) isa typeof (x)
8177 end
8278
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
8589end
0 commit comments