Skip to content

Commit 4341595

Browse files
committed
Better
1 parent 37e3334 commit 4341595

File tree

3 files changed

+49
-10
lines changed

3 files changed

+49
-10
lines changed

src/dense.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ mode(::AutoFiniteDiff) = ForwardMode()
111111
function Base.show(io::IO, backend::AutoFiniteDiff)
112112
print(io, AutoFiniteDiff, "(")
113113
backend.fdtype != Val(:forward) &&
114-
print(io, "fdtype=", repr(backend.fdtype; context = io), ",")
114+
print(io, "fdtype=", repr(backend.fdtype; context = io), ", ")
115115
backend.fdjtype != backend.fdtype &&
116-
print(io, "fdjtype=", repr(backend.fdjtype; context = io), ",")
116+
print(io, "fdjtype=", repr(backend.fdjtype; context = io), ", ")
117117
backend.fdhtype != Val(:hcentral) &&
118-
print(io, "fdhtype=", repr(backend.fdhtype; context = io), ",")
118+
print(io, "fdhtype=", repr(backend.fdhtype; context = io))
119119
print(io, ")")
120120
end
121121

@@ -175,8 +175,9 @@ mode(::AutoForwardDiff) = ForwardMode()
175175

176176
function Base.show(io::IO, backend::AutoForwardDiff{chunksize}) where {chunksize}
177177
print(io, AutoForwardDiff, "(")
178-
chunksize !== nothing && print(io, "chunksize=", repr(chunksize; context = io), ",")
179-
backend.tag !== nothing && print(io, "tag=", repr(backend.tag; context = io), ",")
178+
chunksize !== nothing && print(io, "chunksize=", repr(chunksize; context = io),
179+
(backend.tag !== nothing ? ", " : ""))
180+
backend.tag !== nothing && print(io, "tag=", repr(backend.tag; context = io))
180181
print(io, ")")
181182
end
182183

@@ -211,8 +212,9 @@ mode(::AutoPolyesterForwardDiff) = ForwardMode()
211212

212213
function Base.show(io::IO, backend::AutoPolyesterForwardDiff{chunksize}) where {chunksize}
213214
print(io, AutoPolyesterForwardDiff, "(")
214-
chunksize !== nothing && print(io, "chunksize=", repr(chunksize; context = io), ",")
215-
backend.tag !== nothing && print(io, "tag=", repr(backend.tag; context = io), ",")
215+
chunksize !== nothing && print(io, "chunksize=", repr(chunksize; context = io),
216+
(backend.tag !== nothing ? ", " : ""))
217+
backend.tag !== nothing && print(io, "tag=", repr(backend.tag; context = io))
216218
print(io, ")")
217219
end
218220

src/sparse.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ function AutoSparse(
155155
end
156156

157157
function Base.show(io::IO, backend::AutoSparse)
158-
print(io, AutoSparse, "(dense_ad=", repr(backend.dense_ad, context = io), ",")
158+
print(io, AutoSparse, "(dense_ad=", repr(backend.dense_ad, context = io))
159159
if backend.sparsity_detector != NoSparsityDetector()
160-
print(io, "sparsity_detector=", repr(backend.sparsity_detector, context = io), ",")
160+
print(io, ", sparsity_detector=", repr(backend.sparsity_detector, context = io))
161161
end
162162
if backend.coloring_algorithm != NoColoringAlgorithm()
163163
print(
164-
io, "coloring_algorithm=", repr(backend.coloring_algorithm, context = io), ",")
164+
io, ", coloring_algorithm=", repr(backend.coloring_algorithm, context = io))
165165
end
166166
print(io, ")")
167167
end

test/misc.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,40 @@ end
2020
@test contains(string(sparse_backend1), string(AutoForwardDiff()))
2121
@test length(string(sparse_backend1)) < length(string(sparse_backend2))
2222
end
23+
24+
import ADTypes
25+
26+
struct FakeSparsityDetector <: ADTypes.AbstractSparsityDetector end
27+
struct FakeColoringAlgorithm <: ADTypes.AbstractColoringAlgorithm end
28+
29+
for backend in [
30+
# dense
31+
ADTypes.AutoChainRules(; ruleconfig = :rc),
32+
ADTypes.AutoDiffractor(),
33+
ADTypes.AutoEnzyme(),
34+
ADTypes.AutoEnzyme(mode = :forward),
35+
ADTypes.AutoFastDifferentiation(),
36+
ADTypes.AutoFiniteDiff(),
37+
ADTypes.AutoFiniteDiff(fdtype = :fd, fdjtype = :fdj, fdhtype = :fdh),
38+
ADTypes.AutoFiniteDifferences(; fdm = :fdm),
39+
ADTypes.AutoForwardDiff(),
40+
ADTypes.AutoForwardDiff(chunksize = 3, tag = :tag),
41+
ADTypes.AutoPolyesterForwardDiff(),
42+
ADTypes.AutoPolyesterForwardDiff(chunksize = 3, tag = :tag),
43+
ADTypes.AutoReverseDiff(),
44+
ADTypes.AutoReverseDiff(compile = true),
45+
ADTypes.AutoSymbolics(),
46+
ADTypes.AutoTapir(),
47+
ADTypes.AutoTapir(safe_mode = false),
48+
ADTypes.AutoTracker(),
49+
ADTypes.AutoZygote(),
50+
# sparse
51+
ADTypes.AutoSparse(ADTypes.AutoForwardDiff()),
52+
ADTypes.AutoSparse(
53+
ADTypes.AutoForwardDiff();
54+
sparsity_detector = FakeSparsityDetector(),
55+
coloring_algorithm = FakeColoringAlgorithm()
56+
)
57+
]
58+
println(backend)
59+
end

0 commit comments

Comments
 (0)