Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reapply formatter #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
style = "sciml"
format_markdown = true
format_markdown = true
format_docstrings = true
16 changes: 8 additions & 8 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
include("pages.jl")

makedocs(sitename = "MultiScaleArrays.jl",
authors = "Chris Rackauckas",
modules = [MultiScaleArrays],
clean = true, doctest = false, linkcheck = true,
warnonly = [:missing_docs],
format = Documenter.HTML(assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/MultiScaleArrays/stable/"),
pages = pages)
authors = "Chris Rackauckas",
modules = [MultiScaleArrays],
clean = true, doctest = false, linkcheck = true,
warnonly = [:missing_docs],
format = Documenter.HTML(assets = ["assets/favicon.ico"],
canonical = "https://docs.sciml.ai/MultiScaleArrays/stable/"),
pages = pages)

deploydocs(repo = "github.com/SciML/MultiScaleArrays.jl.git";
push_preview = true)
push_preview = true)
2 changes: 1 addition & 1 deletion docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

pages = [
"Home" => "index.md",
"multiscalearray.md",
"multiscalearray.md"
]
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ file and the
[project]($link_project)
file.
""")
```
```
2 changes: 1 addition & 1 deletion src/MultiScaleArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ organ3 = Organ([1.2, 2.2, 3.2], :Shoot, OrganParams(true))
organ4 = Organ([4.2, 5.2, 6.2], :Root, OrganParams(1 // 3))
plant1 = construct(Plant, (deepcopy(organ1), deepcopy(organ2)), Float64[], PlantSettings(1))
plant2 = construct(Plant, (deepcopy(organ3), deepcopy(organ4)), Float64[],
PlantSettings(1.0))
PlantSettings(1.0))
community = construct(Community, (deepcopy(plant1), deepcopy(plant2)))
scenario = construct(Scenario, (deepcopy(community),))
```
Expand Down
4 changes: 2 additions & 2 deletions src/addition_deletion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function __add_node!(m::AbstractMultiScaleArray, node::AbstractMultiScaleArray,
end

function __add_node!(m::AbstractMultiScaleArray, node::AbstractMultiScaleArray, i,
I::Int...)
I::Int...)
__add_node!(m.nodes[i], node, I...)
__update_lengths(m, i, length(node))
end
Expand All @@ -32,7 +32,7 @@ function add_node!(m::AbstractMultiScaleArrayHead, node::AbstractMultiScaleArray
end

function add_node!(m::AbstractMultiScaleArrayHead, node::AbstractMultiScaleArray, i,
I::Int...)
I::Int...)
__add_node!(m, node, i, I...)
end

Expand Down
72 changes: 36 additions & 36 deletions src/diffeq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,40 @@ end
reshape(m::AbstractMultiScaleArray, i::Int...) = m

function remove_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator, idxs,
node...)
node...)
remove_node_non_user_cache!(integrator, integrator.cache, node...)
end

function remove_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator,
cache::OrdinaryDiffEq.OrdinaryDiffEqCache, idxs,
node...)
cache::OrdinaryDiffEq.OrdinaryDiffEqCache, idxs,
node...)
nothing
end

function add_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator, idxs,
x::AbstractArray)
x::AbstractArray)
add_node_non_user_cache!(integrator, integrator.cache, x)
end

function add_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator, idxs,
x::AbstractArray, node...)
x::AbstractArray, node...)
add_node_non_user_cache!(integrator, integrator.cache, x, node...)
end

function add_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator,
cache::OrdinaryDiffEq.OrdinaryDiffEqCache,
x::AbstractArray)
cache::OrdinaryDiffEq.OrdinaryDiffEqCache,
x::AbstractArray)
nothing
end
function add_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator,
cache::OrdinaryDiffEq.OrdinaryDiffEqCache,
x::AbstractArray, node...)
cache::OrdinaryDiffEq.OrdinaryDiffEqCache,
x::AbstractArray, node...)
nothing
end

function add_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator,
cache::OrdinaryDiffEq.RosenbrockMutableCache,
x::AbstractArray)
cache::OrdinaryDiffEq.RosenbrockMutableCache,
x::AbstractArray)
i = length(integrator.u)
cache.J = similar(cache.J, i, i)
cache.W = similar(cache.W, i, i)
Expand All @@ -92,8 +92,8 @@ function add_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator,
end

function add_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator,
cache::OrdinaryDiffEq.RosenbrockMutableCache,
x::AbstractArray, node...)
cache::OrdinaryDiffEq.RosenbrockMutableCache,
x::AbstractArray, node...)
i = length(integrator.u)
cache.J = similar(cache.J, i, i)
cache.W = similar(cache.W, i, i)
Expand All @@ -103,8 +103,8 @@ function add_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator,
end

function remove_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrator,
cache::OrdinaryDiffEq.RosenbrockMutableCache,
node...)
cache::OrdinaryDiffEq.RosenbrockMutableCache,
node...)
i = length(integrator.u)
cache.J = similar(cache.J, i, i)
cache.W = similar(cache.W, i, i)
Expand All @@ -114,32 +114,32 @@ function remove_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrato
end

function add_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x,
node...)
node...)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
config.chunksize)
nothing
end

function add_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
config.chunksize)
nothing
end

function remove_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x,
node...)
node...)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
config.chunksize)
nothing
end

function remove_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
config.chunksize)
nothing
end

Expand Down Expand Up @@ -183,40 +183,40 @@ function remove_node_grad_config!(cache, grad_config::ForwardDiff.DerivativeConf
end

function remove_node_grad_config!(cache, grad_config::ForwardDiff.DerivativeConfig, i, x,
I...)
I...)
cache.grad_config = ForwardDiff.DerivativeConfig(cache.tf, cache.du1, cache.uf.t)
nothing
end

function add_node_grad_config!(cache, grad_config::AbstractArray, i, x)
cache.grad_config = ForwardDiff.Dual{
typeof(ForwardDiff.Tag(cache.tf,
eltype(cache.du1)))
}.(cache.du1, cache.du1)
typeof(ForwardDiff.Tag(cache.tf,
eltype(cache.du1)))
}.(cache.du1, cache.du1)
nothing
end

function add_node_grad_config!(cache, grad_config::AbstractArray, i, x, I...)
cache.grad_config = ForwardDiff.Dual{
typeof(ForwardDiff.Tag(cache.tf,
eltype(cache.du1)))
}.(cache.du1, cache.du1)
typeof(ForwardDiff.Tag(cache.tf,
eltype(cache.du1)))
}.(cache.du1, cache.du1)
nothing
end

function remove_node_grad_config!(cache, grad_config::AbstractArray, i, x)
cache.grad_config = ForwardDiff.Dual{
typeof(ForwardDiff.Tag(cache.tf,
eltype(cache.du1)))
}.(cache.du1, cache.du1)
typeof(ForwardDiff.Tag(cache.tf,
eltype(cache.du1)))
}.(cache.du1, cache.du1)
nothing
end

function remove_node_grad_config!(cache, grad_config::AbstractArray, i, x, I...)
cache.grad_config = ForwardDiff.Dual{
typeof(ForwardDiff.Tag(cache.tf,
eltype(cache.du1)))
}.(cache.du1, cache.du1)
typeof(ForwardDiff.Tag(cache.tf,
eltype(cache.du1)))
}.(cache.du1, cache.du1)
nothing
end

Expand All @@ -242,7 +242,7 @@ function remove_node_grad_config!(cache, grad_config::FiniteDiff.GradientCache,
end

function add_node_non_user_cache!(integrator::DiffEqBase.AbstractSDEIntegrator, idxs, x,
node...)
node...)
#addat_non_user_cache!(integrator, idxs)
if DiffEqBase.is_diagonal_noise(integrator.sol.prob)
add_node_noise!(integrator, idxs, x, node...)
Expand All @@ -263,7 +263,7 @@ function add_node_non_user_cache!(integrator::DiffEqBase.AbstractSDEIntegrator,
end

function remove_node_non_user_cache!(integrator::DiffEqBase.AbstractSDEIntegrator, idxs,
node...)
node...)
#deleteat_non_user_cache!(integrator, idxs)
if DiffEqBase.is_diagonal_noise(integrator.sol.prob)
remove_node_noise!(integrator, node...)
Expand Down
6 changes: 3 additions & 3 deletions src/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ end

function getindices(m::AbstractMultiScaleArray, bot_idx, top_idx, i, I::Int...)
getindices(m.nodes[i],
bot_idx + ((i > 1) ? m.end_idxs[i - 1] : 0),
top_idx + m.end_idxs[i] - length(m),
I...)
bot_idx + ((i > 1) ? m.end_idxs[i - 1] : 0),
top_idx + m.end_idxs[i] - length(m),
I...)
end

function getindices(m::AbstractMultiScaleArrayLeaf, bot_idx, top_idx, i::Int)
Expand Down
2 changes: 1 addition & 1 deletion src/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end
end

@inline function Base.copyto!(dest::AbstractMultiScaleArrayLeaf,
bc::Broadcast.Broadcasted{<:AMSAStyle})
bc::Broadcast.Broadcasted{<:AMSAStyle})
copyto!(dest.values, unpack(bc, nothing))
dest
end
Expand Down
46 changes: 24 additions & 22 deletions src/print_human_readable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function take_first_char(s::Union{String, SubString{String}}, N::Int64)
end

function toprint_AbstractMultiScaleArray!(toprint, X::AbstractMultiScaleArray, fields,
levelmax, n_char_per_name, level = 1)
levelmax, n_char_per_name, level = 1)
if length(toprint) < level
push!(toprint, Vector{String}())
end
Expand All @@ -20,28 +20,30 @@ function toprint_AbstractMultiScaleArray!(toprint, X::AbstractMultiScaleArray, f
for x in X.nodes
if fieldname(typeof(x), 1) == :nodes
push!(toprint[level],
"|" *
take_first_char(split(string(typeof(x)), "{")[1], n_char_per_name))
"|" *
take_first_char(split(string(typeof(x)), "{")[1], n_char_per_name))
first_element = add_separator!(first_element, toprint, level)
toprint_AbstractMultiScaleArray!(toprint, x, fields, levelmax,
n_char_per_name, level + 1)
n_char_per_name, level + 1)
else
if fields == nothing
push!(toprint[level],
take_first_char(split(string(typeof(x)), "{")[1],
n_char_per_name))
take_first_char(split(string(typeof(x)), "{")[1],
n_char_per_name))
first_element = add_separator!(first_element, toprint, level)
else
if !(x isa AbstractMultiScaleArrayLeaf)
push!(toprint[level],
take_first_char(split(string(typeof(x)), "{")[1],
n_char_per_name))
take_first_char(split(string(typeof(x)), "{")[1],
n_char_per_name))
first_element = add_separator!(first_element, toprint, level)
else
push!(toprint[level],
join([take_first_char(string(field), n_char_per_name) * ": " *
string(getfield(x, Symbol(field)))
for field in collect(fields)], ", "))
join(
[take_first_char(string(field), n_char_per_name) * ": " *
string(getfield(x, Symbol(field)))
for field in collect(fields)],
", "))
first_element = add_separator!(first_element, toprint, level)
end
end
Expand Down Expand Up @@ -80,7 +82,7 @@ print_human_readable(embryo.nodes[1].nodes[1]; fields = [:values])
```
"""
function print_human_readable(X::AbstractMultiScaleArray; n_char_per_name = 6,
fields = nothing, levelmax = Inf, n_item_max_per_levels = Inf) # fields = nothing OR [field1,field2,...]
fields = nothing, levelmax = Inf, n_item_max_per_levels = Inf) # fields = nothing OR [field1,field2,...]
# if X isa AbstractMultiScaleArrayLeaf
# println(X)
# else
Expand Down Expand Up @@ -119,18 +121,18 @@ function print_human_readable(X::AbstractMultiScaleArray; n_char_per_name = 6,
Move = findfirst("+ ", toprint[level])[1]
To = findnext(" |", toprint[level], Move[end])[1]
toprint[level] = join([
toprint[level][1:(Move - 1)],
toprint[level][(Move + 1):To],
toprint[level][Move],
toprint[level][(To + 1):end],
])
toprint[level][1:(Move - 1)],
toprint[level][(Move + 1):To],
toprint[level][Move],
toprint[level][(To + 1):end]
])
for level_ in 1:(level - 1)
toprint[level_] = join([
toprint[level_][1:(Move - 1)],
toprint[level_][(To + 1):(To + To - Move)],
toprint[level_][Move:To],
toprint[level_][(To + To - Move + 1):end],
])
toprint[level_][1:(Move - 1)],
toprint[level_][(To + 1):(To + To - Move)],
toprint[level_][Move:To],
toprint[level_][(To + To - Move + 1):end]
])
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/shape_construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end
(sq = Meta.quot(s); :(deepcopy(getfield(m, $sq))))
for s in fieldnames(m)[4:end]] # 1:3 is nodes,values,end_idxs
:(construct(parameterless_type(m), recursive_similar(m.nodes, T), similar(m.values, T),
$(assignments...)))
$(assignments...)))
end

Base.zero(A::AbstractMultiScaleArray) = fill!(similar(A), 0)
Expand Down
Loading
Loading