Skip to content

Commit

Permalink
Add to doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill committed Sep 5, 2024
1 parent ad0eca5 commit 471f812
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/adtypes_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ For local sparsity patterns at a specific input point, use [`TracerLocalSparsity
```jldoctest
julia> using SparseConnectivityTracer
julia> jacobian_sparsity(diff, rand(4), TracerSparsityDetector())
julia> detector = TracerSparsityDetector()
TracerSparsityDetector()
julia> jacobian_sparsity(diff, rand(4), detector)
3×4 SparseArrays.SparseMatrixCSC{Bool, Int64} with 6 stored entries:
1 1 ⋅ ⋅
⋅ 1 1 ⋅
Expand All @@ -29,7 +32,7 @@ julia> jacobian_sparsity(diff, rand(4), TracerSparsityDetector())
```jldoctest

Check failure on line 32 in src/adtypes_interface.jl

View workflow job for this annotation

GitHub Actions / Documentation

doctest failure in ~/work/SparseConnectivityTracer.jl/SparseConnectivityTracer.jl/src/adtypes_interface.jl:32-41 ```jldoctest julia> f(x) = x[1] + x[2]*x[3] + 1/x[4]; julia> hessian_sparsity(f, rand(4), detector) 4×4 SparseArrays.SparseMatrixCSC{Bool, Int64} with 3 stored entries: ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1 ⋅ ⋅ 1 ⋅ ⋅ ⋅ ⋅ ⋅ 1 ``` Subexpression: hessian_sparsity(f, rand(4), detector) Evaluated output: ERROR: UndefVarError: `detector` not defined Stacktrace: [1] top-level scope @ none:1 Expected output: 4×4 SparseArrays.SparseMatrixCSC{Bool, Int64} with 3 stored entries: ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1 ⋅ ⋅ 1 ⋅ ⋅ ⋅ ⋅ ⋅ 1 diff = Warning: Diff output requires color. 4×4 SparseArrays.SparseMatrixCSC{Bool, Int64} with 3 stored entries: ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1 ⋅ ⋅ 1 ⋅ ⋅ ⋅ ⋅ ⋅ 1ERROR: UndefVarError: `detector` not defined Stacktrace: [1] top-level scope @ none:1
julia> f(x) = x[1] + x[2]*x[3] + 1/x[4];
julia> hessian_sparsity(f, rand(4), TracerSparsityDetector())
julia> hessian_sparsity(f, rand(4), detector)
4×4 SparseArrays.SparseMatrixCSC{Bool, Int64} with 3 stored entries:
⋅ ⋅ ⋅ ⋅
⋅ ⋅ 1 ⋅
Expand Down Expand Up @@ -78,23 +81,24 @@ Local sparsity patterns are less convervative than global patterns and need to b
```jldoctest
julia> using SparseConnectivityTracer
julia> method = TracerLocalSparsityDetector();
julia> detector = TracerLocalSparsityDetector()
TracerLocalSparsityDetector()
julia> f(x) = x[1] * x[2]; # J_f = [x[2], x[1]]
julia> jacobian_sparsity(f, [1, 0], method)
julia> jacobian_sparsity(f, [1, 0], detector)
1×2 SparseArrays.SparseMatrixCSC{Bool, Int64} with 1 stored entry:
⋅ 1
julia> jacobian_sparsity(f, [0, 1], method)
julia> jacobian_sparsity(f, [0, 1], detector)
1×2 SparseArrays.SparseMatrixCSC{Bool, Int64} with 1 stored entry:
1 ⋅
julia> jacobian_sparsity(f, [0, 0], method)
julia> jacobian_sparsity(f, [0, 0], detector)
1×2 SparseArrays.SparseMatrixCSC{Bool, Int64} with 0 stored entries:
⋅ ⋅
julia> jacobian_sparsity(f, [1, 1], method)
julia> jacobian_sparsity(f, [1, 1], detector)
1×2 SparseArrays.SparseMatrixCSC{Bool, Int64} with 2 stored entries:
1 1
```
Expand Down

0 comments on commit 471f812

Please sign in to comment.