Skip to content

Commit 90367ab

Browse files
Check that rrule x_ad DNE
1 parent 5220f30 commit 90367ab

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ChainRulesTestUtils"
22
uuid = "cdddcdb0-9152-4a09-a978-84456f9df70a"
3-
version = "0.1.2"
3+
version = "0.1.3"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/ChainRulesTestUtils.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,13 @@ function rrule_test(f, ȳ, xx̄s::Tuple{Any, Any}...; rtol=1e-9, atol=1e-9, fdm
175175

176176
# Correctness testing via finite differencing.
177177
x̄s_fd = _make_fdm_call(fdm, f, ȳ, xs, x̄s .== nothing)
178-
map(x̄s_ad, x̄s_fd) do x̄_ad, x̄_fd
179-
@test isapprox(x̄_ad, x̄_fd; rtol=rtol, atol=atol, kwargs...)
178+
for (x̄_ad, x̄_fd) in zip(x̄s_ad, x̄s_fd)
179+
if x̄_fd === nothing
180+
# The way we've structured the above, this tests that the rule is a DoesNotExistRule
181+
@test x̄_ad isa DoesNotExist
182+
else
183+
@test isapprox(x̄_ad, x̄_fd; rtol=rtol, atol=atol, kwargs...)
184+
end
180185
end
181186
end
182187

0 commit comments

Comments
 (0)