Skip to content

Commit 7a9600e

Browse files
authored
add test_approx(::Zero, ::Array{Array}) (#257)
1 parent 5b9ec32 commit 7a9600e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/check_result.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ for (T1, T2) in
4040
end
4141

4242
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...)
4344
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...)
4446
test_approx(x::ZeroTangent, y::ZeroTangent, msg=""; kwargs...) = @test true
4547
test_approx(x::NoTangent, y::NoTangent, msg=""; kwargs...) = @test true
4648

test/check_result.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ end
3636

3737
test_approx([1.0, 2.0], [1.0, 2.0])
3838
test_approx([[1.0], [2.0]], [[1.0], [2.0]])
39+
test_approx([[0.0], [0.0]], ZeroTangent())
40+
test_approx(ZeroTangent(), [[0.0], [0.0]])
3941
test_approx(Broadcast.broadcasted(identity, [1.0 2.0; 3.0 4.0]), [1.0 2.0; 3.0 4.0])
4042

4143
test_approx(@thunk(10 * 0.1 * [[1.0], [2.0]]), [[1.0], [2.0]])
@@ -108,6 +110,8 @@ end
108110

109111
@test fails(() -> test_approx([1.0, 2.0], [1.0, 3.9]))
110112
@test fails(() -> test_approx([[1.0], [2.0]], [[1.1], [2.0]]))
113+
@test fails(() -> test_approx([[0.0], [0.1]], ZeroTangent()))
114+
@test fails(() -> test_approx(ZeroTangent(), [[0.1], [0.0]]))
111115

112116
@test fails(() -> test_approx(@thunk(10 * [[1.0], [2.0]]), [[1.0], [2.0]]))
113117

0 commit comments

Comments
 (0)