Skip to content

Commit

Permalink
Check that rrule x_ad DNE
Browse files Browse the repository at this point in the history
  • Loading branch information
mattBrzezinski committed Feb 5, 2020
1 parent 80dae08 commit 4e6f049
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ChainRulesTestUtils"
uuid = "cdddcdb0-9152-4a09-a978-84456f9df70a"
version = "0.1.2"
version = "0.1.3"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
9 changes: 7 additions & 2 deletions src/ChainRulesTestUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,13 @@ function rrule_test(f, ȳ, xx̄s::Tuple{Any, Any}...; rtol=1e-9, atol=1e-9, fdm

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

Expand Down

0 comments on commit 4e6f049

Please sign in to comment.