Skip to content

Commit 2df1434

Browse files
author
Miha Zgubic
committed
use NoTangent instead of nothing
1 parent c73d49f commit 2df1434

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/finite_difference_calls.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Call `FiniteDifferences.j′vp`, with the option to ignore certain `xs`.
3535
- `ȳ`: The adjoint w.r.t. output of `f`.
3636
- `xs`: Inputs to `f`, such that `y = f(xs...)`.
3737
- `ignores`: Collection of `Bool`s, the same length as `xs`.
38-
If `ignores[i] === true`, then `xs[i]` is ignored; `∂xs[i] === nothing`.
38+
If `ignores[i] === true`, then `xs[i]` is ignored; `∂xs[i] === NoTangent()`.
3939
4040
# Returns
4141
- `∂xs::Tuple`: Derivatives estimated by finite differencing.
@@ -44,7 +44,7 @@ function _make_j′vp_call(fdm, f, ȳ, xs, ignores)
4444
f2 = _wrap_function(f, xs, ignores)
4545

4646
ignores = collect(ignores)
47-
args = Any[nothing for _ in 1:length(xs)]
47+
args = Any[NoTangent() for _ in 1:length(xs)]
4848
all(ignores) && return NoTangent()
4949
sigargs = xs[.!ignores]
5050
arginds = (1:length(xs))[.!ignores]
@@ -66,7 +66,7 @@ Return a new version of `f`, `fnew`, that ignores some of the arguments `xs`.
6666
- `f`: The function to be wrapped.
6767
- `xs`: Inputs to `f`, such that `y = f(xs...)`.
6868
- `ignores`: Collection of `Bool`s, the same length as `xs`.
69-
If `ignores[i] === true`, then `xs[i]` is ignored; `∂xs[i] === nothing`.
69+
If `ignores[i] === true`, then `xs[i]` is ignored; `∂xs[i] === NoTangent()`.
7070
"""
7171
function _wrap_function(f, xs, ignores)
7272
function fnew(sigargs...)

src/testers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function test_rrule(
225225
accum_cotangents, ad_cotangents, fd_cotangents
226226
)
227227
if accum_cotangent isa NoTangent # then we marked this argument as not differentiable
228-
@assert fd_cotangent === nothing # this is how `_make_j′vp_call` works
228+
@assert fd_cotangent === NoTangent()
229229
ad_cotangent isa ZeroTangent && error(
230230
"The pullback in the rrule should use NoTangent()" *
231231
" rather than ZeroTangent() for non-perturbable arguments.",

0 commit comments

Comments
 (0)