Skip to content

Commit f82cbc3

Browse files
Merge pull request #57 from SciML/format
format SciML Style
2 parents 3df81a9 + 7b2e176 commit f82cbc3

21 files changed

+686
-569
lines changed

.JuliaFormatter.toml

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

.github/workflows/FormatCheck.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: format-check
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'release-'
8+
tags: '*'
9+
pull_request:
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
julia-version: [1]
17+
julia-arch: [x86]
18+
os: [ubuntu-latest]
19+
steps:
20+
- uses: julia-actions/setup-julia@latest
21+
with:
22+
version: ${{ matrix.julia-version }}
23+
24+
- uses: actions/checkout@v1
25+
- name: Install JuliaFormatter and format
26+
# This will use the latest version by default but you can set the version like so:
27+
#
28+
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
29+
run: |
30+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
31+
julia -e 'using JuliaFormatter; format(".", verbose=true)'
32+
- name: Format check
33+
run: |
34+
julia -e '
35+
out = Cmd(`git diff --name-only`) |> read |> String
36+
if out == ""
37+
exit(0)
38+
else
39+
@error "Some files have not been formatted !!!"
40+
write(stdout, out)
41+
exit(1)
42+
end'

docs/make.jl

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

33
include("pages.jl")
44

5-
makedocs(
6-
sitename="MultiScaleArrays.jl",
7-
authors="Chris Rackauckas",
8-
modules=[MultiScaleArrays],
9-
clean=true,doctest=false,
10-
format = Documenter.HTML(analytics = "UA-90474609-3",
11-
assets = ["assets/favicon.ico"],
12-
canonical="https://multiscalearrays.sciml.ai/stable/"),
13-
pages=pages
14-
)
5+
makedocs(sitename = "MultiScaleArrays.jl",
6+
authors = "Chris Rackauckas",
7+
modules = [MultiScaleArrays],
8+
clean = true, doctest = false,
9+
format = Documenter.HTML(analytics = "UA-90474609-3",
10+
assets = ["assets/favicon.ico"],
11+
canonical = "https://multiscalearrays.sciml.ai/stable/"),
12+
pages = pages)
1513

16-
deploydocs(
17-
repo = "github.com/SciML/MultiScaleArrays.jl.git";
18-
push_preview = true
19-
)
14+
deploydocs(repo = "github.com/SciML/MultiScaleArrays.jl.git";
15+
push_preview = true)

docs/pages.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Put in a separate page so it can be used by SciMLDocs.jl
22

3-
pages=[
3+
pages = [
44
"Home" => "index.md",
5-
"multiscalearray.md"
6-
]
5+
"multiscalearray.md",
6+
]

src/MultiScaleArrays.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ __precompile__()
33
module MultiScaleArrays
44

55
import Base: length, push!, deleteat!, getindex, setindex!, eachindex, ndims,
6-
size, print_matrix, similar, hcat, vcat,
7-
==, *, +, /, -, show, vec, reshape
6+
size, print_matrix, similar, hcat, vcat,
7+
==, *, +, /, -, show, vec, reshape
88

9-
import RecursiveArrayTools: recursivecopy,recursivecopy!
9+
import RecursiveArrayTools: recursivecopy, recursivecopy!
1010

1111
import RecursiveArrayTools: chain
1212

@@ -161,7 +161,7 @@ scenario = construct(Scenario, (deepcopy(community),))
161161
162162
(of course at the cost of mutability).
163163
"""
164-
abstract type AbstractMultiScaleArray{B} <: AbstractVector{B} end
164+
abstract type AbstractMultiScaleArray{B} <: AbstractVector{B} end
165165
abstract type AbstractMultiScaleArrayLeaf{B} <: AbstractMultiScaleArray{B} end
166166
abstract type AbstractMultiScaleArrayHead{B} <: AbstractMultiScaleArray{B} end
167167

@@ -183,8 +183,6 @@ using TreeViews
183183
TreeViews.hastreeview(x::AbstractMultiScaleArray) = true
184184
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::AbstractMultiScaleArray) = x
185185

186-
187-
188186
# Types
189187
export AbstractMultiScaleArray, AbstractMultiScaleArrayLeaf,
190188
AbstractMultiScaleArrayHead

src/addition_deletion.jl

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function __add_node!(m::AbstractMultiScaleArray, node::AbstractMultiScaleArray)
55
end
66

77
function __update_lengths(m::AbstractMultiScaleArray, beg, len)
8-
for j = beg:num_nodes(m)
8+
for j in beg:num_nodes(m)
99
m.end_idxs[j] += len
1010
end
1111
isempty(m.values) || (m.end_idxs[end] += len)
@@ -17,25 +17,30 @@ function __add_node!(m::AbstractMultiScaleArray, node::AbstractMultiScaleArray,
1717
__update_lengths(m, i, length(node))
1818
end
1919

20-
function __add_node!(m::AbstractMultiScaleArray, node::AbstractMultiScaleArray, i, I::Int...)
20+
function __add_node!(m::AbstractMultiScaleArray, node::AbstractMultiScaleArray, i,
21+
I::Int...)
2122
__add_node!(m.nodes[i], node, I...)
2223
__update_lengths(m, i, length(node))
2324
end
2425

25-
add_node!(m::AbstractMultiScaleArrayHead, node::AbstractMultiScaleArray) =
26+
function add_node!(m::AbstractMultiScaleArrayHead, node::AbstractMultiScaleArray)
2627
__add_node!(m, node)
28+
end
2729

28-
add_node!(m::AbstractMultiScaleArrayHead, node::AbstractMultiScaleArray, i::Int) =
30+
function add_node!(m::AbstractMultiScaleArrayHead, node::AbstractMultiScaleArray, i::Int)
2931
__add_node!(m, node, i)
32+
end
3033

31-
add_node!(m::AbstractMultiScaleArrayHead, node::AbstractMultiScaleArray, i, I::Int...) =
34+
function add_node!(m::AbstractMultiScaleArrayHead, node::AbstractMultiScaleArray, i,
35+
I::Int...)
3236
__add_node!(m, node, i, I...)
37+
end
3338

3439
function __remove_node!(m::AbstractMultiScaleArray, i::Int)
3540
del_length = length(m.nodes[i])
3641
deleteat!(m.nodes, i)
3742
deleteat!(m.end_idxs, i)
38-
for j = i:num_nodes(m)
43+
for j in i:num_nodes(m)
3944
m.end_idxs[j] -= del_length
4045
end
4146
isempty(m.values) || (m.end_idxs[end] -= del_length)
@@ -49,11 +54,11 @@ end
4954

5055
function remove_node!(m::AbstractMultiScaleArrayHead, i, I::Int...)
5156
del_length = __remove_node!(m.nodes[i], I...)
52-
for j = i:num_nodes(m)
57+
for j in i:num_nodes(m)
5358
m.end_idxs[j] -= del_length
5459
end
5560
isempty(m.values) || (m.end_idxs[end] -= del_length)
56-
if size(m.nodes[i].nodes) == (0, )
61+
if size(m.nodes[i].nodes) == (0,)
5762
deleteat!(m.nodes, i)
5863
deleteat!(m.end_idxs, i)
5964
end
@@ -62,13 +67,12 @@ end
6267

6368
function __remove_node!(m::AbstractMultiScaleArray, i, I::Int...)
6469
del_length = __remove_node!(m.nodes[i], I...)
65-
for j = i:num_nodes(m)
70+
for j in i:num_nodes(m)
6671
m.end_idxs[j] -= del_length
6772
end
6873
isempty(m.values) || (m.end_idxs[end] -= del_length)
6974
isempty(m.nodes[i]) && deleteat!(m.nodes, i)
7075
del_length
7176
end
7277

73-
remove_node!(m::AbstractMultiScaleArrayHead, i::Int) =
74-
(__remove_node!(m, i); nothing)
78+
remove_node!(m::AbstractMultiScaleArrayHead, i::Int) = (__remove_node!(m, i); nothing)

0 commit comments

Comments
 (0)