Skip to content

Commit 7d59afa

Browse files
Merge pull request #66 from ArnoStrouwen/doc_improv
various doc and style improvements
2 parents 9478422 + cc2be51 commit 7d59afa

File tree

9 files changed

+109
-72
lines changed

9 files changed

+109
-72
lines changed

.JuliaFormatter.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
style = "sciml"
1+
style = "sciml"
2+
format_markdown = true

LICENSE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ The MultiScaleModels.jl package is licensed under the MIT "Expat" License:
1919
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
> SOFTWARE.
22-
>

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![codecov](https://codecov.io/gh/SciML/MultiScaleArrays.jl/branch/master/graph/badge.svg?token=FwXaKBNW67)](https://codecov.io/gh/SciML/MultiScaleArrays.jl)
77
[![Build Status](https://github.com/SciML/MultiScaleArrays.jl/workflows/CI/badge.svg)](https://github.com/SciML/MultiScaleArrays.jl/actions?query=workflow%3ACI)
88

9-
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
9+
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
1010
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)
1111

1212
MultiScaleArrays.jl allows you to easily build multiple scale models which are
@@ -38,17 +38,17 @@ using MultiScaleArrays
3838
struct Cell{B} <: AbstractMultiScaleArrayLeaf{B}
3939
values::Vector{B}
4040
end
41-
struct Population{T<:AbstractMultiScaleArray,B<:Number} <: AbstractMultiScaleArray{B}
41+
struct Population{T <: AbstractMultiScaleArray, B <: Number} <: AbstractMultiScaleArray{B}
4242
nodes::Vector{T}
4343
values::Vector{B}
4444
end_idxs::Vector{Int}
4545
end
46-
struct Tissue{T<:AbstractMultiScaleArray,B<:Number} <: AbstractMultiScaleArray{B}
46+
struct Tissue{T <: AbstractMultiScaleArray, B <: Number} <: AbstractMultiScaleArray{B}
4747
nodes::Vector{T}
4848
values::Vector{B}
4949
end_idxs::Vector{Int}
5050
end
51-
struct Embryo{T<:AbstractMultiScaleArray,B<:Number} <: AbstractMultiScaleArrayHead{B}
51+
struct Embryo{T <: AbstractMultiScaleArray, B <: Number} <: AbstractMultiScaleArrayHead{B}
5252
nodes::Vector{T}
5353
values::Vector{B}
5454
end_idxs::Vector{Int}
@@ -59,22 +59,18 @@ This setup defines a type structure which is both a tree and an array. A picture
5959
version is the following:
6060

6161
<img src="https://user-images.githubusercontent.com/1814174/27211626-79fe1b9a-520f-11e7-87f1-1cb33da91609.PNG">
62-
6362
Let's build a version of this. Using the constructors we can directly construct leaf types:
64-
6563
```julia
6664
cell1 = Cell([1.0; 2.0; 3.0])
6765
cell2 = Cell([4.0; 5.0])
6866
```
69-
7067
and build types higher up in the hierarchy by using the `constuct` method. The method
7168
is `construct(T::AbstractMultiScaleArray, nodes, values)`, though if `values` is not given it's
7269
taken to be empty.
73-
7470
```julia
7571
cell3 = Cell([3.0; 2.0; 5.0])
7672
cell4 = Cell([4.0; 6.0])
77-
population = construct(Population, deepcopy([cell1, cell3, cell4]))
73+
population = construct(Population, deepcopy([cell1, cell3, cell4]))
7874
population2 = construct(Population, deepcopy([cell1, cell3, cell4]))
7975
population3 = construct(Population, deepcopy([cell1, cell3, cell4]))
8076
tissue1 = construct(Tissue, deepcopy([population, population2, population3])) # Make a Tissue from Populations

docs/make.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ include("pages.jl")
88
makedocs(sitename = "MultiScaleArrays.jl",
99
authors = "Chris Rackauckas",
1010
modules = [MultiScaleArrays],
11-
clean = true, doctest = false,
11+
clean = true, doctest = false, linkcheck = true,
12+
strict = [
13+
:doctest,
14+
:linkcheck,
15+
:parse_error,
16+
:example_block,
17+
# Other available options are
18+
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
19+
],
1220
format = Documenter.HTML(analytics = "UA-90474609-3",
1321
assets = ["assets/favicon.ico"],
1422
canonical = "https://docs.sciml.ai/MultiScaleArrays/stable/"),

docs/src/index.md

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ using MultiScaleArrays
3131
struct Cell{B} <: AbstractMultiScaleArrayLeaf{B}
3232
values::Vector{B}
3333
end
34-
struct Population{T<:AbstractMultiScaleArray,B<:Number} <: AbstractMultiScaleArray{B}
34+
struct Population{T <: AbstractMultiScaleArray, B <: Number} <: AbstractMultiScaleArray{B}
3535
nodes::Vector{T}
3636
values::Vector{B}
3737
end_idxs::Vector{Int}
3838
end
39-
struct Tissue{T<:AbstractMultiScaleArray,B<:Number} <: AbstractMultiScaleArray{B}
39+
struct Tissue{T <: AbstractMultiScaleArray, B <: Number} <: AbstractMultiScaleArray{B}
4040
nodes::Vector{T}
4141
values::Vector{B}
4242
end_idxs::Vector{Int}
4343
end
44-
struct Embryo{T<:AbstractMultiScaleArray,B<:Number} <: AbstractMultiScaleArrayHead{B}
44+
struct Embryo{T <: AbstractMultiScaleArray, B <: Number} <: AbstractMultiScaleArrayHead{B}
4545
nodes::Vector{T}
4646
values::Vector{B}
4747
end_idxs::Vector{Int}
@@ -53,21 +53,21 @@ version is the following:
5353

5454
![](https://user-images.githubusercontent.com/1814174/27211626-79fe1b9a-520f-11e7-87f1-1cb33da91609.PNG)
5555

56-
Let's build a version of this. Using the constructors we can directly construct leaf types:
56+
Let's build a version of this. Using the constructors, we can directly construct leaf types:
5757

5858
```julia
5959
cell1 = Cell([1.0; 2.0; 3.0])
6060
cell2 = Cell([4.0; 5.0])
6161
```
6262

6363
and build types higher up in the hierarchy by using the `constuct` method. The method
64-
is `construct(T::AbstractMultiScaleArray, nodes, values)`, though if `values` is not given it's
64+
is `construct(T::AbstractMultiScaleArray, nodes, values)`, though, if `values` is not given it's
6565
taken to be empty.
6666

6767
```julia
6868
cell3 = Cell([3.0; 2.0; 5.0])
6969
cell4 = Cell([4.0; 6.0])
70-
population = construct(Population, deepcopy([cell1, cell3, cell4]))
70+
population = construct(Population, deepcopy([cell1, cell3, cell4]))
7171
population2 = construct(Population, deepcopy([cell1, cell3, cell4]))
7272
population3 = construct(Population, deepcopy([cell1, cell3, cell4]))
7373
tissue1 = construct(Tissue, deepcopy([population, population2, population3])) # Make a Tissue from Populations
@@ -95,66 +95,87 @@ techniques for each new model.
9595

9696
## Contributing
9797

98-
- Please refer to the
99-
[SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://github.com/SciML/ColPrac/blob/master/README.md)
100-
for guidance on PRs, issues, and other matters relating to contributing to ModelingToolkit.
101-
- There are a few community forums:
102-
- the #diffeq-bridged channel in the [Julia Slack](https://julialang.org/slack/)
103-
- [JuliaDiffEq](https://gitter.im/JuliaDiffEq/Lobby) on Gitter
104-
- on the [Julia Discourse forums](https://discourse.julialang.org)
105-
- see also [SciML Community page](https://sciml.ai/community/)
98+
- Please refer to the
99+
[SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://github.com/SciML/ColPrac/blob/master/README.md)
100+
for guidance on PRs, issues, and other matters relating to contributing to SciML.
101+
102+
- See the [SciML Style Guide](https://github.com/SciML/SciMLStyle) for common coding practices and other style decisions.
103+
- There are a few community forums:
104+
105+
+ The #diffeq-bridged and #sciml-bridged channels in the
106+
[Julia Slack](https://julialang.org/slack/)
107+
+ The #diffeq-bridged and #sciml-bridged channels in the
108+
[Julia Zulip](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
109+
+ On the [Julia Discourse forums](https://discourse.julialang.org)
110+
+ See also [SciML Community page](https://sciml.ai/community/)
106111

107112
## Reproducibility
113+
108114
```@raw html
109115
<details><summary>The documentation of this SciML package was built using these direct dependencies,</summary>
110116
```
117+
111118
```@example
112119
using Pkg # hide
113120
Pkg.status() # hide
114121
```
122+
115123
```@raw html
116124
</details>
117125
```
126+
118127
```@raw html
119128
<details><summary>and using this machine and Julia version.</summary>
120129
```
130+
121131
```@example
122132
using InteractiveUtils # hide
123133
versioninfo() # hide
124134
```
135+
125136
```@raw html
126137
</details>
127138
```
139+
128140
```@raw html
129141
<details><summary>A more complete overview of all dependencies and their versions is also provided.</summary>
130142
```
143+
131144
```@example
132145
using Pkg # hide
133-
Pkg.status(;mode = PKGMODE_MANIFEST) # hide
146+
Pkg.status(; mode = PKGMODE_MANIFEST) # hide
134147
```
148+
135149
```@raw html
136150
</details>
137151
```
152+
138153
```@raw html
139154
You can also download the
140155
<a href="
141156
```
157+
142158
```@eval
143159
using TOML
144-
version = TOML.parse(read("../../Project.toml",String))["version"]
145-
name = TOML.parse(read("../../Project.toml",String))["name"]
146-
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Manifest.toml"
160+
version = TOML.parse(read("../../Project.toml", String))["version"]
161+
name = TOML.parse(read("../../Project.toml", String))["name"]
162+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
163+
"/assets/Manifest.toml"
147164
```
165+
148166
```@raw html
149167
">manifest</a> file and the
150168
<a href="
151169
```
170+
152171
```@eval
153172
using TOML
154-
version = TOML.parse(read("../../Project.toml",String))["version"]
155-
name = TOML.parse(read("../../Project.toml",String))["name"]
156-
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Project.toml"
173+
version = TOML.parse(read("../../Project.toml", String))["version"]
174+
name = TOML.parse(read("../../Project.toml", String))["name"]
175+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
176+
"/assets/Project.toml"
157177
```
178+
158179
```@raw html
159180
">project</a> file.
160-
```
181+
```

docs/src/multiscalearray.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ applies normal random numbers to the three values. We could use this to add to t
6262
model the fact that `tissue.values[1:3]` are the tissue's position, and `f` would then be
6363
adding Brownian motion.
6464

65-
Of course, you can keep going and kind of do whatever you want. The power is yours!
65+
Of course, you can keep going and kind of do whatever you want. The power is yours!

src/MultiScaleArrays.jl

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,28 @@ highest level of the model or the head extends MultiScaleModelHead, and all
1818
intermediate types extend AbstractMultiScaleArray. The leaf has an array `values::Vector{B}`.
1919
Each type above then contains three fields:
2020
21-
- `nodes::Vector{T}`
22-
- `values::Vector{B}`
23-
- `end_idxs::Vector{Int}`
21+
- `nodes::Vector{T}`
22+
- `values::Vector{B}`
23+
- `end_idxs::Vector{Int}`
2424
2525
Note that the ordering of the fields matters.
2626
`B` is the `BottomType`, which has to be the same as the eltype for the array
2727
in the leaf types. `T` is another `AbstractMultiScaleArray`. Thus at each level,
2828
an` AbstractMultiScaleArray` contains some information of its own (`values`), the
29-
next level down in the heirarchy (`nodes`), and caching for indices (`end_idxs`).
29+
next level down in the hierarchy (`nodes`), and caching for indices (`end_idxs`).
3030
You can add and use extra fields as you please, and even make the types immutable.
3131
3232
## The MultiScaleModel API
3333
3434
The resulting type acts as an array. A leaf type `l` acts exactly as an array
3535
with `l[i] == l.values[i]`. Higher nodes also act as a linear array. If `ln` is level
36-
`n` in the heirarchy, then `ln.nodes` is the vector of level `n-1` objects, and `ln.values`
36+
`n` in the hierarchy, then `ln.nodes` is the vector of level `n-1` objects, and `ln.values`
3737
are its "intrinsic values". There is an indexing scheme on `ln`, where:
3838
39-
- `ln[i,j,k]` gets the `k`th `n-3` object in the `j`th `n-2` object in the `i`th level `n-1`
40-
object. Of course, this recurses for the whole hierarchy.
41-
- `ln[i]` provides a linear index through all `.nodes` and `.values` values in every lower
42-
level and `ln.values` itself.
39+
- `ln[i,j,k]` gets the `k`th `n-3` object in the `j`th `n-2` object in the `i`th level `n-1`
40+
object. Of course, this recurses for the whole hierarchy.
41+
- `ln[i]` provides a linear index through all `.nodes` and `.values` values in every lower
42+
level and `ln.values` itself.
4343
4444
Thus `typeof(ln) <: AbstractVector{B}` where `B` is the eltype of its leaves and
4545
all `.values`'s.
@@ -66,7 +66,7 @@ operations:
6666
6767
```julia
6868
embryo[10] = 4.0 # changes protein concentration 10
69-
embryo[2,3,1] # Gives the 1st cell in the 3rd population of the second tissue
69+
embryo[2, 3, 1] # Gives the 1st cell in the 3rd population of the second tissue
7070
embryo[:] # generates a vector of all of the protein concentrations
7171
eachindex(embryo) # generates an iterator for the indices
7272
```
@@ -77,18 +77,18 @@ Using the iterators, note that we can get each cell population by looping throug
7777
2 levels below the top, so
7878
7979
```julia
80-
for cell in level_iter(embryo,3)
81-
# Do something with the cells!
80+
for cell in level_iter(embryo, 3)
81+
# Do something with the cells!
8282
end
8383
```
8484
8585
or the multiple level iter, which is the one generally used in
8686
DifferentialEquations.jl functions:
8787
8888
```julia
89-
for (cell, dcell) in LevelIter(3,embryo, dembryo)
89+
for (cell, dcell) in LevelIter(3, embryo, dembryo)
9090
# If these are similar structures, `cell` and `dcell` are the similar parts
91-
cell_ode(dcell,cell,p,t)
91+
cell_ode(dcell, cell, p, t)
9292
end
9393
```
9494
@@ -112,7 +112,7 @@ remove_node!(embryo, 2, 1) # Removes population 1 from tissue 2 of the embryo
112112
```
113113
114114
Combined with event handling, this allows for dynamic structures to be derived from
115-
low level behaviors.
115+
low-level behaviors.
116116
117117
## Heterogeneous Nodes via Tuples
118118
@@ -121,41 +121,47 @@ heterogeneous nodes. This could be useful for mixing types
121121
inside of the nodes. For example:
122122
123123
```julia
124-
struct PlantSettings{T} x::T end
125-
struct OrganParams{T} y::T end
124+
struct PlantSettings{T}
125+
x::T
126+
end
127+
struct OrganParams{T}
128+
y::T
129+
end
126130
127-
struct Organ{B<:Number,P} <: AbstractMultiScaleArrayLeaf{B}
131+
struct Organ{B <: Number, P} <: AbstractMultiScaleArrayLeaf{B}
128132
values::Vector{B}
129133
name::Symbol
130134
params::P
131135
end
132136
133-
struct Plant{B,S,N<:Tuple{Vararg{<:Organ{<:Number}}}} <: AbstractMultiScaleArray{B}
137+
struct Plant{B, S, N <: Tuple{Vararg{<:Organ{<:Number}}}} <: AbstractMultiScaleArray{B}
134138
nodes::N
135139
values::Vector{B}
136140
end_idxs::Vector{Int}
137141
settings::S
138142
end
139143
140-
struct Community{B,N<:Tuple{Vararg{<:Plant{<:Number}}}} <: AbstractMultiScaleArray{B}
144+
struct Community{B, N <: Tuple{Vararg{<:Plant{<:Number}}}} <: AbstractMultiScaleArray{B}
141145
nodes::N
142146
values::Vector{B}
143147
end_idxs::Vector{Int}
144148
end
145149
146-
mutable struct Scenario{B,N<:Tuple{Vararg{<:Community{<:Number}}}} <: AbstractMultiScaleArrayHead{B}
150+
mutable struct Scenario{B, N <: Tuple{Vararg{<:Community{<:Number}}}} <:
151+
AbstractMultiScaleArrayHead{B}
147152
nodes::N
148153
values::Vector{B}
149154
end_idxs::Vector{Int}
150155
end
151156
152-
organ1 = Organ([1.1,2.1,3.1], :Shoot, OrganParams(:grows_up))
153-
organ2 = Organ([4.1,5.1,6.1], :Root, OrganParams("grows down"))
154-
organ3 = Organ([1.2,2.2,3.2], :Shoot, OrganParams(true))
155-
organ4 = Organ([4.2,5.2,6.2], :Root, OrganParams(1//3))
157+
organ1 = Organ([1.1, 2.1, 3.1], :Shoot, OrganParams(:grows_up))
158+
organ2 = Organ([4.1, 5.1, 6.1], :Root, OrganParams("grows down"))
159+
organ3 = Organ([1.2, 2.2, 3.2], :Shoot, OrganParams(true))
160+
organ4 = Organ([4.2, 5.2, 6.2], :Root, OrganParams(1 // 3))
156161
plant1 = construct(Plant, (deepcopy(organ1), deepcopy(organ2)), Float64[], PlantSettings(1))
157-
plant2 = construct(Plant, (deepcopy(organ3), deepcopy(organ4)), Float64[], PlantSettings(1.0))
158-
community = construct(Community, (deepcopy(plant1), deepcopy(plant2), ))
162+
plant2 = construct(Plant, (deepcopy(organ3), deepcopy(organ4)), Float64[],
163+
PlantSettings(1.0))
164+
community = construct(Community, (deepcopy(plant1), deepcopy(plant2)))
159165
scenario = construct(Scenario, (deepcopy(community),))
160166
```
161167

src/math.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ nnodes(A, Bs...) = common_number(nnodes(A), _nnodes(Bs))
6969
_nnodes(args::Tuple{Any}) = nnodes(args[1])
7070
_nnodes(args::Tuple{}) = 0
7171

72-
"`A = find_amsa(As)` returns the first AMSA among the arguments."
72+
"""
73+
`A = find_amsa(As)` returns the first AMSA among the arguments.
74+
"""
7375
find_amsa(bc::Base.Broadcast.Broadcasted) = find_amsa(bc.args)
7476
find_amsa(args::Tuple) = !isempty(args) && find_amsa(find_amsa(args[1]), Base.tail(args))
7577
find_amsa(x) = x

0 commit comments

Comments
 (0)