@@ -40,12 +40,17 @@ for (T1, T2) in
40
40
end
41
41
42
42
test_approx (:: AbstractZero , x, msg= " " ; kwargs... ) = test_approx (zero (x), x, msg; kwargs... )
43
- test_approx (:: AbstractZero , x:: AbstractArray{<:AbstractArray} , msg= " " ; kwargs... ) = test_approx (map (zero, x), x, msg; kwargs... )
44
43
test_approx (x, :: AbstractZero , msg= " " ; kwargs... ) = test_approx (x, zero (x), msg; kwargs... )
45
- test_approx (x:: AbstractArray{<:AbstractArray} , :: AbstractZero , msg= " " ; kwargs... ) = test_approx (x, map (zero, x), msg; kwargs... )
46
44
test_approx (x:: ZeroTangent , y:: ZeroTangent , msg= " " ; kwargs... ) = @test true
47
45
test_approx (x:: NoTangent , y:: NoTangent , msg= " " ; kwargs... ) = @test true
48
46
47
+ function test_approx (z:: AbstractZero , x:: AbstractArray{<:AbstractArray} , msg= " " ; kwargs... )
48
+ for el in x
49
+ test_approx (el, z, msg; kwargs... )
50
+ end
51
+ end
52
+ test_approx (x:: AbstractArray{<:AbstractArray} , z:: AbstractZero , msg= " " ; kwargs... ) = test_approx (z, x, msg; kwargs... )
53
+
49
54
# remove once https://github.com/JuliaDiff/ChainRulesTestUtils.jl/issues/113
50
55
test_approx (x:: NoTangent , y:: Nothing , msg= " " ; kwargs... ) = @test true
51
56
test_approx (x:: Nothing , y:: NoTangent , msg= " " ; kwargs... ) = @test true
@@ -134,8 +139,8 @@ function test_approx(actual::Tangent{P,T}, expected, msg=""; kwargs...) where {T
134
139
end
135
140
test_approx (x, y:: Tangent , msg= " " ; kwargs... ) = test_approx (y, x, msg; kwargs... )
136
141
137
- test_approx (z:: NoTangent , t:: Tangent , msg= " " ; kwargs... ) = all (== (NoTangent ()), t)
138
- test_approx (t:: Tangent , z:: NoTangent , msg= " " ; kwargs... ) = all (== (NoTangent ()), t)
142
+ test_approx (z:: NoTangent , t:: Tangent , msg= " " ; kwargs... ) = @test all (== (NoTangent ()), t)
143
+ test_approx (t:: Tangent , z:: NoTangent , msg= " " ; kwargs... ) = @test all (== (NoTangent ()), t)
139
144
140
145
# This catches comparisons of Tangents and Tuples/NamedTuple
141
146
# and gives an error message complaining about that. the `@test` will definitely fail
0 commit comments