Skip to content

Commit 0f71a42

Browse files
authored
Fix doctest (#219)
1 parent 66f1fdc commit 0f71a42

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

DifferentiationInterface/docs/src/backends.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ You can check this compatibility using [`check_twoarg`](@ref).
7070
Only some backends are able to compute Hessians.
7171
You can use [`check_hessian`](@ref) to check this feature.
7272

73-
74-
## API Reference
73+
## API reference
7574

7675
!!! warning
7776
The following documentation has been re-exported from [ADTypes.jl](https://github.com/SciML/ADTypes.jl).
7877
Refer to the ADTypes documentation for more information.
7978

8079
```@docs
80+
ADTypes
81+
ADTypes.AbstractADType
8182
AutoChainRules
8283
AutoDiffractor
8384
AutoEnzyme
@@ -92,4 +93,4 @@ AutoTapir
9293
AutoTracker
9394
AutoZygote
9495
AutoSparse
95-
```
96+
```

DifferentiationInterface/docs/src/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ We make this available for all backends with the following operators:
123123
| :--------------------------------- | :---------------------------------- |
124124
| [`value_and_pullback_split`](@ref) | [`value_and_pullback!_split`](@ref) |
125125

126-
## Translation
126+
### Translation
127127

128128
The wrapper [`DifferentiateWith`](@ref) allows you to take a function and specify that it should be differentiated with the backend of your choice.
129129
In other words, when you try to differentiate `dw = DifferentiateWith(f, backend1)` with `backend2`, then `backend1` steps in and `backend2` does nothing.

DifferentiationInterface/src/translation/differentiate_with.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This works by defining new rules overriding the behavior of the outer backend th
2020
2121
# Example
2222
23-
```@repl
23+
```jldoctest
2424
using DifferentiationInterface
2525
import ForwardDiff, Zygote
2626
@@ -32,8 +32,12 @@ end
3232
3333
dw = DifferentiateWith(f, AutoForwardDiff());
3434
35-
gradient(dw, AutoZygote(), [1.0, 2.0]) # works because it calls ForwardDiff instead
36-
gradient(f, AutoZygote(), [1.0, 2.0]) # fails
35+
gradient(dw, AutoZygote(), [2.0]) # calls ForwardDiff instead
36+
37+
# output
38+
39+
1-element Vector{Float64}:
40+
1.0
3741
```
3842
"""
3943
struct DifferentiateWith{F,B<:AbstractADType}

0 commit comments

Comments
 (0)