Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit c6a3871

Browse files
committed
add formatter toml
1 parent c8a0a31 commit c6a3871

28 files changed

Lines changed: 1063 additions & 1291 deletions

.JuliaFormatter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style = "sciml"

docs/make.jl

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@ using Documenter, SparseDiffTools
22

33
include("pages.jl")
44

5-
makedocs(
6-
sitename = "SparseDiffTools.jl",
7-
authors = "Chris Rackauckas",
8-
modules = [SparseDiffTools],
9-
clean = true,
10-
doctest = false,
11-
format = Documenter.HTML(
12-
assets = ["assets/favicon.ico"],
13-
canonical = "https://docs.sciml.ai/SparseDiffTools/stable/",
14-
),
15-
pages = pages,
16-
)
5+
makedocs(sitename = "SparseDiffTools.jl",
6+
authors = "Chris Rackauckas",
7+
modules = [SparseDiffTools],
8+
clean = true,
9+
doctest = false,
10+
format = Documenter.HTML(assets = ["assets/favicon.ico"],
11+
canonical = "https://docs.sciml.ai/SparseDiffTools/stable/"),
12+
pages = pages)
1713

18-
deploydocs(
19-
repo = "https://github.com/JuliaDiff/SparseDiffTools.jl.git";
20-
push_preview = true,
21-
)
14+
deploydocs(repo = "https://github.com/JuliaDiff/SparseDiffTools.jl.git";
15+
push_preview = true)

src/SparseDiffTools.jl

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,39 @@ using DataStructures: DisjointSets, find_root!, union!
2020
using ArrayInterfaceCore: matrix_colors
2121

2222
export contract_color,
23-
greedy_d1,
24-
greedy_star1_coloring,
25-
greedy_star2_coloring,
26-
matrix2graph,
27-
matrix_colors,
28-
forwarddiff_color_jacobian!,
29-
forwarddiff_color_jacobian,
30-
ForwardColorJacCache,
31-
numauto_color_hessian!,
32-
numauto_color_hessian,
33-
autoauto_color_hessian!,
34-
autoauto_color_hessian,
35-
ForwardColorHesCache,
36-
ForwardAutoColorHesCache,
37-
auto_jacvec,
38-
auto_jacvec!,
39-
num_jacvec,
40-
num_jacvec!,
41-
num_vecjac,
42-
num_vecjac!,
43-
num_hesvec,
44-
num_hesvec!,
45-
numauto_hesvec,
46-
numauto_hesvec!,
47-
autonum_hesvec,
48-
autonum_hesvec!,
49-
num_hesvecgrad,
50-
num_hesvecgrad!,
51-
auto_hesvecgrad,
52-
auto_hesvecgrad!,
53-
JacVec,
54-
HesVec,
55-
HesVecGrad
56-
23+
greedy_d1,
24+
greedy_star1_coloring,
25+
greedy_star2_coloring,
26+
matrix2graph,
27+
matrix_colors,
28+
forwarddiff_color_jacobian!,
29+
forwarddiff_color_jacobian,
30+
ForwardColorJacCache,
31+
numauto_color_hessian!,
32+
numauto_color_hessian,
33+
autoauto_color_hessian!,
34+
autoauto_color_hessian,
35+
ForwardColorHesCache,
36+
ForwardAutoColorHesCache,
37+
auto_jacvec,
38+
auto_jacvec!,
39+
num_jacvec,
40+
num_jacvec!,
41+
num_vecjac,
42+
num_vecjac!,
43+
num_hesvec,
44+
num_hesvec!,
45+
numauto_hesvec,
46+
numauto_hesvec!,
47+
autonum_hesvec,
48+
autonum_hesvec!,
49+
num_hesvecgrad,
50+
num_hesvecgrad!,
51+
auto_hesvecgrad,
52+
auto_hesvecgrad!,
53+
JacVec,
54+
HesVec,
55+
HesVecGrad
5756

5857
include("coloring/high_level.jl")
5958
include("coloring/backtracking_coloring.jl")
@@ -73,9 +72,9 @@ parameterless_type(x) = parameterless_type(typeof(x))
7372
parameterless_type(x::Type) = __parameterless_type(x)
7473

7574
function __init__()
76-
@require Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" begin
75+
@require Zygote="e88e6eb3-aa80-5325-afca-941959d7151f" begin
7776
export numback_hesvec,
78-
numback_hesvec!, autoback_hesvec, autoback_hesvec!, auto_vecjac, auto_vecjac!
77+
numback_hesvec!, autoback_hesvec, autoback_hesvec!, auto_vecjac, auto_vecjac!
7978

8079
include("differentiation/vecjac_products_zygote.jl")
8180
include("differentiation/jaches_products_zygote.jl")

src/coloring/acyclic_coloring.jl

Lines changed: 35 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,14 @@ function color_graph(g::Graphs.AbstractGraph, ::AcyclicColoring)
3030
for x in outneighbors(g, w)
3131
if color[x] != 0
3232
if forbidden_colors[color[x]] != v
33-
prevent_cycle!(
34-
first_visit_to_tree,
35-
forbidden_colors,
36-
v,
37-
w,
38-
x,
39-
g,
40-
two_colored_forest,
41-
color,
42-
)
33+
prevent_cycle!(first_visit_to_tree,
34+
forbidden_colors,
35+
v,
36+
w,
37+
x,
38+
g,
39+
two_colored_forest,
40+
color)
4341
end
4442
end
4543
end
@@ -69,7 +67,6 @@ function color_graph(g::Graphs.AbstractGraph, ::AcyclicColoring)
6967
return color
7068
end
7169

72-
7370
"""
7471
prevent_cycle!(first_visit_to_tree::AbstractVector{<:Tuple{Integer,Integer}},
7572
forbidden_colors::AbstractVector{<:Integer},
@@ -85,16 +82,14 @@ which is adjacent to vertices w and x in graph g. Disjoint set is used to store
8582
the induced 2-colored subgraphs/trees where the id of set is an integer
8683
representing an edge of graph 'g'
8784
"""
88-
function prevent_cycle!(
89-
first_visit_to_tree::AbstractVector{<:Tuple{Integer,Integer}},
90-
forbidden_colors::AbstractVector{<:Integer},
91-
v::Integer,
92-
w::Integer,
93-
x::Integer,
94-
g::Graphs.AbstractGraph,
95-
two_colored_forest::DisjointSets{<:Integer},
96-
color::AbstractVector{<:Integer},
97-
)
85+
function prevent_cycle!(first_visit_to_tree::AbstractVector{<:Tuple{Integer, Integer}},
86+
forbidden_colors::AbstractVector{<:Integer},
87+
v::Integer,
88+
w::Integer,
89+
x::Integer,
90+
g::Graphs.AbstractGraph,
91+
two_colored_forest::DisjointSets{<:Integer},
92+
color::AbstractVector{<:Integer})
9893
e = find(w, x, g, two_colored_forest)
9994
p, q = first_visit_to_tree[e]
10095

@@ -105,7 +100,6 @@ function prevent_cycle!(
105100
end
106101
end
107102

108-
109103
"""
110104
grow_star!(two_colored_forest::DisjointSets{<:Integer},
111105
first_neighbor::AbstractVector{<: Tuple{Integer,Integer}},
@@ -119,14 +113,12 @@ previously uncolored vertex v, by comparing it with the adjacent vertex w.
119113
Disjoint set is used to store stars in sets, which are identified through key
120114
edges present in g.
121115
"""
122-
function grow_star!(
123-
two_colored_forest::DisjointSets{<:Integer},
124-
first_neighbor::AbstractVector{<:Tuple{Integer,Integer}},
125-
v::Integer,
126-
w::Integer,
127-
g::Graphs.AbstractGraph,
128-
color::AbstractVector{<:Integer},
129-
)
116+
function grow_star!(two_colored_forest::DisjointSets{<:Integer},
117+
first_neighbor::AbstractVector{<:Tuple{Integer, Integer}},
118+
v::Integer,
119+
w::Integer,
120+
g::Graphs.AbstractGraph,
121+
color::AbstractVector{<:Integer})
130122
insert_new_tree!(two_colored_forest, v, w, g)
131123
p, q = first_neighbor[color[w]]
132124

@@ -139,7 +131,6 @@ function grow_star!(
139131
end
140132
end
141133

142-
143134
"""
144135
merge_trees!(two_colored_forest::DisjointSets{<:Integer},
145136
v::Integer,
@@ -150,21 +141,18 @@ end
150141
Subroutine to merge trees present in the disjoint set which have a
151142
common edge.
152143
"""
153-
function merge_trees!(
154-
two_colored_forest::DisjointSets{<:Integer},
155-
v::Integer,
156-
w::Integer,
157-
x::Integer,
158-
g::Graphs.AbstractGraph,
159-
)
144+
function merge_trees!(two_colored_forest::DisjointSets{<:Integer},
145+
v::Integer,
146+
w::Integer,
147+
x::Integer,
148+
g::Graphs.AbstractGraph)
160149
e1 = find(v, w, g, two_colored_forest)
161150
e2 = find(w, x, g, two_colored_forest)
162151
if e1 != e2
163152
union!(two_colored_forest, e1, e2)
164153
end
165154
end
166155

167-
168156
"""
169157
insert_new_tree!(two_colored_forest::DisjointSets{<:Integer},
170158
v::Integer,
@@ -174,17 +162,14 @@ end
174162
creates a new singleton set in the disjoint set 'two_colored_forest' consisting
175163
of the edge connecting v and w in the graph g
176164
"""
177-
function insert_new_tree!(
178-
two_colored_forest::DisjointSets{<:Integer},
179-
v::Integer,
180-
w::Integer,
181-
g::Graphs.AbstractGraph,
182-
)
165+
function insert_new_tree!(two_colored_forest::DisjointSets{<:Integer},
166+
v::Integer,
167+
w::Integer,
168+
g::Graphs.AbstractGraph)
183169
edge_index = find_edge_index(v, w, g)
184170
push!(two_colored_forest, edge_index)
185171
end
186172

187-
188173
"""
189174
min_index(forbidden_colors::AbstractVector{<:Integer}, v::Integer)
190175
@@ -194,7 +179,6 @@ function min_index(forbidden_colors::AbstractVector{<:Integer}, v::Integer)
194179
return findfirst(!isequal(v), forbidden_colors)
195180
end
196181

197-
198182
"""
199183
find(w::Integer,
200184
x::Integer,
@@ -204,17 +188,14 @@ end
204188
Returns the root of the disjoint set to which the edge connecting vertices w and x
205189
in the graph g belongs to
206190
"""
207-
function find(
208-
w::Integer,
209-
x::Integer,
210-
g::Graphs.AbstractGraph,
211-
two_colored_forest::DisjointSets{<:Integer},
212-
)
191+
function find(w::Integer,
192+
x::Integer,
193+
g::Graphs.AbstractGraph,
194+
two_colored_forest::DisjointSets{<:Integer})
213195
edge_index = find_edge_index(w, x, g)
214196
return find_root!(two_colored_forest, edge_index)
215197
end
216198

217-
218199
"""
219200
find_edge(g::Graphs.AbstractGraph, v::Integer, w::Integer)
220201
@@ -224,7 +205,6 @@ v and w in the graph g
224205
function find_edge_index(v::Integer, w::Integer, g::Graphs.AbstractGraph)
225206
pos = 1
226207
for i in edges(g)
227-
228208
if (src(i) == v && dst(i) == w) || (src(i) == w && dst(i) == v)
229209
return pos
230210
end

0 commit comments

Comments
 (0)