Skip to content

Commit 326b018

Browse files
committed
Switch from JuliaFormatter to Runic.jl for code formatting
- Update CI workflow to use fredrikekre/runic-action@v1 - Remove .JuliaFormatter.toml configuration - Format all source files with Runic.jl 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 172f015 commit 326b018

14 files changed

Lines changed: 189 additions & 144 deletions

.JuliaFormatter.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/FormatCheck.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: format-check
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'main'
8+
- 'release-'
9+
tags: '*'
10+
pull_request:
11+
12+
jobs:
13+
runic:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: fredrikekre/runic-action@v1
18+
with:
19+
version: '1'

ext/ADTypesChainRulesCoreExt.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ module ADTypesChainRulesCoreExt
22

33
using ADTypes: ADTypes, AutoChainRules
44
using ChainRulesCore: HasForwardsMode, HasReverseMode,
5-
NoForwardsMode, NoReverseMode,
6-
RuleConfig
5+
NoForwardsMode, NoReverseMode,
6+
RuleConfig
77

88
# see https://juliadiff.org/ChainRulesCore.jl/stable/rule_author/superpowers/ruleconfig.html
99

1010
function ADTypes.mode(::AutoChainRules{RC}) where {
11-
RC <: RuleConfig{>:HasForwardsMode}
12-
}
11+
RC <: RuleConfig{>:HasForwardsMode},
12+
}
1313
return ADTypes.ForwardMode()
1414
end
1515

1616
function ADTypes.mode(::AutoChainRules{RC}) where {
17-
RC <: RuleConfig{>:HasReverseMode}
18-
}
17+
RC <: RuleConfig{>:HasReverseMode},
18+
}
1919
return ADTypes.ReverseMode()
2020
end
2121

2222
function ADTypes.mode(::AutoChainRules{RC}) where {
23-
RC <: RuleConfig{>:Union{HasForwardsMode, HasReverseMode}}
24-
}
23+
RC <: RuleConfig{>:Union{HasForwardsMode, HasReverseMode}},
24+
}
2525
# more specific than the previous two
2626
return ADTypes.ForwardOrReverseMode()
2727
end

src/ADTypes.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@ include("symbols.jl")
2929
# Automatic Differentiation
3030
export AbstractADType
3131
export AutoChainRules,
32-
AutoDiffractor,
33-
AutoEnzyme,
34-
AutoFastDifferentiation,
35-
AutoFiniteDiff,
36-
AutoFiniteDifferences,
37-
AutoForwardDiff,
38-
AutoGTPSA,
39-
AutoModelingToolkit,
40-
AutoMooncake,
41-
AutoMooncakeForward,
42-
AutoPolyesterForwardDiff,
43-
AutoReverseDiff,
44-
AutoSymbolics,
45-
AutoTapir,
46-
AutoTaylorDiff,
47-
AutoTracker,
48-
AutoZygote,
49-
NoAutoDiff,
50-
NoAutoDiffSelectedError,
51-
AutoReactant
32+
AutoDiffractor,
33+
AutoEnzyme,
34+
AutoFastDifferentiation,
35+
AutoFiniteDiff,
36+
AutoFiniteDifferences,
37+
AutoForwardDiff,
38+
AutoGTPSA,
39+
AutoModelingToolkit,
40+
AutoMooncake,
41+
AutoMooncakeForward,
42+
AutoPolyesterForwardDiff,
43+
AutoReverseDiff,
44+
AutoSymbolics,
45+
AutoTapir,
46+
AutoTaylorDiff,
47+
AutoTracker,
48+
AutoZygote,
49+
NoAutoDiff,
50+
NoAutoDiffSelectedError,
51+
AutoReactant
5252
@public AbstractMode
5353
@public ForwardMode, ReverseMode, ForwardOrReverseMode, SymbolicMode
5454
@public mode

src/compat.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Backward compatibility with `public` keyword, as suggested in
1+
# Backward compatibility with `public` keyword, as suggested in
22
# https://discourse.julialang.org/t/is-compat-jl-worth-it-for-the-public-keyword/119041/22
33
macro public(ex)
4-
if VERSION >= v"1.11.0-DEV.469"
4+
return if VERSION >= v"1.11.0-DEV.469"
55
args = ex isa Symbol ? (ex,) :
6-
Base.isexpr(ex, :tuple) ? ex.args : error("Failed to mark $ex as public")
6+
Base.isexpr(ex, :tuple) ? ex.args : error("Failed to mark $ex as public")
77
esc(Expr(:public, args...))
88
else
99
nothing

src/dense.jl

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020
mode(::AutoChainRules) = ForwardOrReverseMode() # specialized in the extension
2121

2222
function Base.show(io::IO, backend::AutoChainRules)
23-
print(io, AutoChainRules, "(ruleconfig=", repr(backend.ruleconfig; context = io), ")")
23+
return print(io, AutoChainRules, "(ruleconfig=", repr(backend.ruleconfig; context = io), ")")
2424
end
2525

2626
"""
@@ -68,7 +68,8 @@ struct AutoEnzyme{M, A} <: AbstractADType
6868
end
6969

7070
function AutoEnzyme(;
71-
mode::M = nothing, function_annotation::Type{A} = Nothing) where {M, A}
71+
mode::M = nothing, function_annotation::Type{A} = Nothing
72+
) where {M, A}
7273
return AutoEnzyme{M, A}(mode)
7374
end
7475

@@ -79,7 +80,7 @@ function Base.show(io::IO, backend::AutoEnzyme{M, A}) where {M, A}
7980
!isnothing(backend.mode) && print(io, "mode=", repr(backend.mode; context = io))
8081
!isnothing(backend.mode) && !(A <: Nothing) && print(io, ", ")
8182
!(A <: Nothing) && print(io, "function_annotation=", repr(A; context = io))
82-
print(io, ")")
83+
return print(io, ")")
8384
end
8485

8586

@@ -101,12 +102,13 @@ Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl).
101102
+ an [`AutoEnzyme`](@ref) object if a specific mode is required
102103
+ `nothing` to choose the best mode automatically
103104
"""
104-
struct AutoReactant{M<:AutoEnzyme} <: AbstractADType
105+
struct AutoReactant{M <: AutoEnzyme} <: AbstractADType
105106
mode::M
106107
end
107108

108109
function AutoReactant(;
109-
mode::Union{AutoEnzyme,Nothing} = nothing)
110+
mode::Union{AutoEnzyme, Nothing} = nothing
111+
)
110112
if mode === nothing
111113
mode = AutoEnzyme()
112114
end
@@ -118,7 +120,7 @@ mode(r::AutoReactant) = mode(r.mode)
118120
function Base.show(io::IO, backend::AutoReactant)
119121
print(io, AutoReactant, "(")
120122
print(io, "mode=", repr(backend.mode; context = io))
121-
print(io, ")")
123+
return print(io, ")")
122124
end
123125

124126
"""
@@ -184,7 +186,7 @@ function Base.show(io::IO, backend::AutoFiniteDiff)
184186
print(io, "absstep=", repr(backend.absstep; context = io), ", ")
185187
backend.dir != true &&
186188
print(io, "dir=", repr(backend.dir; context = io))
187-
print(io, ")")
189+
return print(io, ")")
188190
end
189191

190192
"""
@@ -209,7 +211,7 @@ end
209211
mode(::AutoFiniteDifferences) = ForwardMode()
210212

211213
function Base.show(io::IO, backend::AutoFiniteDifferences)
212-
print(io, AutoFiniteDifferences, "(fdm=", repr(backend.fdm; context = io), ")")
214+
return print(io, AutoFiniteDifferences, "(fdm=", repr(backend.fdm; context = io), ")")
213215
end
214216

215217
"""
@@ -245,10 +247,12 @@ mode(::AutoForwardDiff) = ForwardMode()
245247

246248
function Base.show(io::IO, backend::AutoForwardDiff{chunksize}) where {chunksize}
247249
print(io, AutoForwardDiff, "(")
248-
chunksize !== nothing && print(io, "chunksize=", repr(chunksize; context = io),
249-
(backend.tag !== nothing ? ", " : ""))
250+
chunksize !== nothing && print(
251+
io, "chunksize=", repr(chunksize; context = io),
252+
(backend.tag !== nothing ? ", " : "")
253+
)
250254
backend.tag !== nothing && print(io, "tag=", repr(backend.tag; context = io))
251-
print(io, ")")
255+
return print(io, ")")
252256
end
253257

254258
"""
@@ -277,7 +281,7 @@ mode(::AutoTaylorDiff) = ForwardMode()
277281
function Base.show(io::IO, ::AutoTaylorDiff{order}) where {order}
278282
print(io, AutoTaylorDiff, "(")
279283
print(io, "order=", repr(order; context = io))
280-
print(io, ")")
284+
return print(io, ")")
281285
end
282286

283287
"""
@@ -309,7 +313,7 @@ mode(::AutoGTPSA) = ForwardMode()
309313
function Base.show(io::IO, backend::AutoGTPSA{D}) where {D}
310314
print(io, AutoGTPSA, "(")
311315
D != Nothing && print(io, "descriptor=", repr(backend.descriptor; context = io))
312-
print(io, ")")
316+
return print(io, ")")
313317
end
314318

315319
"""
@@ -343,7 +347,7 @@ function Base.show(io::IO, backend::AutoMooncake)
343347
print(io, AutoMooncake, "(")
344348
backend.config !== nothing &&
345349
print(io, "config=", repr(backend.config; context = io))
346-
print(io, ")")
350+
return print(io, ")")
347351
end
348352

349353
"""
@@ -377,7 +381,7 @@ function Base.show(io::IO, backend::AutoMooncakeForward)
377381
print(io, AutoMooncakeForward, "(")
378382
backend.config !== nothing &&
379383
print(io, "config=", repr(backend.config; context = io))
380-
print(io, ")")
384+
return print(io, ")")
381385
end
382386

383387
"""
@@ -415,10 +419,12 @@ mode(::AutoPolyesterForwardDiff) = ForwardMode()
415419

416420
function Base.show(io::IO, backend::AutoPolyesterForwardDiff{chunksize}) where {chunksize}
417421
print(io, AutoPolyesterForwardDiff, "(")
418-
chunksize !== nothing && print(io, "chunksize=", repr(chunksize; context = io),
419-
(backend.tag !== nothing ? ", " : ""))
422+
chunksize !== nothing && print(
423+
io, "chunksize=", repr(chunksize; context = io),
424+
(backend.tag !== nothing ? ", " : "")
425+
)
420426
backend.tag !== nothing && print(io, "tag=", repr(backend.tag; context = io))
421-
print(io, ")")
427+
return print(io, ")")
422428
end
423429

424430
"""
@@ -466,7 +472,8 @@ function Base.getproperty(ad::AutoReverseDiff, s::Symbol)
466472
if s === :compile
467473
Base.depwarn(
468474
"`ad.compile` where `ad` is `AutoReverseDiff` has been deprecated and will be removed in v2. Instead it is available as a compile-time constant as `AutoReverseDiff{true}` or `AutoReverseDiff{false}`.",
469-
:getproperty)
475+
:getproperty
476+
)
470477
end
471478
return getfield(ad, s)
472479
end
@@ -476,7 +483,7 @@ mode(::AutoReverseDiff) = ReverseMode()
476483
function Base.show(io::IO, ::AutoReverseDiff{compile}) where {compile}
477484
print(io, AutoReverseDiff, "(")
478485
compile && print(io, "compile=true")
479-
print(io, ")")
486+
return print(io, ")")
480487
end
481488

482489
"""
@@ -522,7 +529,7 @@ mode(::AutoTapir) = ReverseMode()
522529
function Base.show(io::IO, backend::AutoTapir)
523530
print(io, AutoTapir, "(")
524531
!(backend.safe_mode) && print(io, "safe_mode=false")
525-
print(io, ")")
532+
return print(io, ")")
526533
end
527534

528535
"""

src/legacy.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
@deprecate AutoSparseForwardDiff(; kwargs...) AutoSparse(AutoForwardDiff(; kwargs...))
66

7-
@deprecate AutoSparsePolyesterForwardDiff(; kwargs...) AutoSparse(AutoPolyesterForwardDiff(;
8-
kwargs...))
7+
@deprecate AutoSparsePolyesterForwardDiff(; kwargs...) AutoSparse(
8+
AutoPolyesterForwardDiff(;
9+
kwargs...
10+
)
11+
)
912

1013
@deprecate AutoSparseReverseDiff(; kwargs...) AutoSparse(AutoReverseDiff(; kwargs...))
1114

@@ -26,14 +29,16 @@ end
2629
function AutoModelingToolkit(obj_sparse::Bool, cons_sparse::Bool)
2730
Base.depwarn(
2831
"`AutoModelingToolkit(obj_sparse, cons_sparse)` is deprecated, use `AutoSymbolics()` or `AutoSparse(AutoSymbolics())` instead.",
29-
:AutoModelingToolkit; force = false)
32+
:AutoModelingToolkit; force = false
33+
)
3034
return mtk_to_symbolics(obj_sparse, cons_sparse)
3135
end
3236

3337
function AutoModelingToolkit(; obj_sparse::Bool = false, cons_sparse::Bool = false)
3438
Base.depwarn(
3539
"`AutoModelingToolkit(; obj_sparse, cons_sparse)` is deprecated, use `AutoSymbolics()` or `AutoSparse(AutoSymbolics())` instead.",
36-
:AutoModelingToolkit; force = false)
40+
:AutoModelingToolkit; force = false
41+
)
3742
return mtk_to_symbolics(obj_sparse, cons_sparse)
3843
end
3944

src/sparse.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ Wraps an ADTypes.jl object to deal with sparse Jacobians and Hessians.
191191
)
192192
"""
193193
struct AutoSparse{
194-
D <: AbstractADType,
195-
S <: AbstractSparsityDetector,
196-
C <: AbstractColoringAlgorithm
197-
} <: AbstractADType
194+
D <: AbstractADType,
195+
S <: AbstractSparsityDetector,
196+
C <: AbstractColoringAlgorithm,
197+
} <: AbstractADType
198198
dense_ad::D
199199
sparsity_detector::S
200200
coloring_algorithm::C
@@ -203,11 +203,12 @@ end
203203
function AutoSparse(
204204
dense_ad;
205205
sparsity_detector = NoSparsityDetector(),
206-
coloring_algorithm = NoColoringAlgorithm())
206+
coloring_algorithm = NoColoringAlgorithm()
207+
)
207208
return AutoSparse{
208209
typeof(dense_ad),
209210
typeof(sparsity_detector),
210-
typeof(coloring_algorithm)
211+
typeof(coloring_algorithm),
211212
}(dense_ad, sparsity_detector, coloring_algorithm)
212213
end
213214

@@ -218,9 +219,10 @@ function Base.show(io::IO, backend::AutoSparse)
218219
end
219220
if backend.coloring_algorithm != NoColoringAlgorithm()
220221
print(
221-
io, ", coloring_algorithm=", repr(backend.coloring_algorithm, context = io))
222+
io, ", coloring_algorithm=", repr(backend.coloring_algorithm, context = io)
223+
)
222224
end
223-
print(io, ")")
225+
return print(io, ")")
224226
end
225227

226228
"""

src/symbols.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ ADTypes.AutoZygote()
2222
"""
2323
Auto(package::Symbol, args...; kws...) = Auto(Val(package), args...; kws...)
2424

25-
for backend in (:ChainRules, :Diffractor, :Enzyme, :Reactant, :FastDifferentiation,
26-
:FiniteDiff, :FiniteDifferences, :ForwardDiff, :GTPSA, :Mooncake, :PolyesterForwardDiff,
27-
:ReverseDiff, :Symbolics, :Tapir, :TaylorDiff, :Tracker, :Zygote)
25+
for backend in (
26+
:ChainRules, :Diffractor, :Enzyme, :Reactant, :FastDifferentiation,
27+
:FiniteDiff, :FiniteDifferences, :ForwardDiff, :GTPSA, :Mooncake, :PolyesterForwardDiff,
28+
:ReverseDiff, :Symbolics, :Tapir, :TaylorDiff, :Tracker, :Zygote,
29+
)
2830
@eval Auto(::Val{$(QuoteNode(backend))}, args...; kws...) = $(Symbol(:Auto, backend))(
29-
args...; kws...)
31+
args...; kws...
32+
)
3033
end
3134

3235
Auto(::Nothing) = NoAutoDiff()

0 commit comments

Comments
 (0)