Skip to content

Commit 67a1701

Browse files
author
Fengyu Zhang
committed
Fix formatting issues
1 parent b2d1ca8 commit 67a1701

28 files changed

+585
-515
lines changed

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ makedocs(sitename = "SciMLBase.jl",
1313
format = Documenter.HTML(assets = ["assets/favicon.ico"],
1414
canonical = "https://docs.sciml.ai/SciMLBase/stable"),
1515
linkcheck_ignore = [
16-
"https://www.sciencedirect.com/science/article/abs/pii/S0045782523007156"
16+
"https://www.sciencedirect.com/science/article/abs/pii/S0045782523007156"
1717
],
1818
pages = pages)
1919

docs/src/interfaces/Ensembles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ compute covariance matrices similarly:
476476

477477
```@example ensemble4
478478
timeseries_steps_meancov(sim) # Use the time steps, assume fixed dt
479-
timeseries_point_meancov(sim, 0:(1 // 2^(3)):1, 0:(1 // 2^(3)):1) # Use time points, interpolate
479+
timeseries_point_meancov(sim, 0:(1 // 2 ^ (3)):1, 0:(1 // 2 ^ (3)):1) # Use time points, interpolate
480480
```
481481

482482
For general analysis, we can build a `EnsembleSummary` type.

ext/SciMLBaseChainRulesCoreExt.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ function ChainRulesCore.rrule(
1616
j::Integer)
1717
function ODESolution_getindex_pullback(Δ)
1818
i = symbolic_type(sym) != NotSymbolic() ? variable_index(VA, sym) : sym
19-
du, dprob = if i === nothing
19+
du,
20+
dprob = if i === nothing
2021
getter = getobserved(VA)
2122
grz = rrule_via_ad(config, getter, sym, VA.u[j], VA.prob.p, VA.t[j])[2](Δ)
2223
du = [k == j ? grz[3] : zero(VA.u[1]) for k in 1:length(VA.u)]
@@ -83,7 +84,8 @@ function ChainRulesCore.rrule(
8384
(NoTangent(), ȳ, ntuple(_ -> NoTangent(), length(args))...)
8485
end
8586

86-
ODESolution{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16}(u, args...),
87+
ODESolution{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16}(
88+
u, args...),
8789
ODESolutionAdjoint
8890
end
8991

@@ -99,7 +101,7 @@ function ChainRulesCore.rrule(
99101
end
100102

101103
RODESolution{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
102-
T11, T12, T13, T14}(u, args...),
104+
T11, T12, T13, T14}(u, args...),
103105
RODESolutionAdjoint
104106
end
105107

ext/SciMLBaseMakieExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ function Makie.convert_arguments(PT::Type{<:Plot},
105105
@assert tscale isa Symbol "`tscale` if passed in to `Makie.plot` must be a Symbol, got a $(typeof(tscale))"
106106

107107
# Convert the solution to arrays - this is the hard part!
108-
plot_vecs, labels = SciMLBase.diffeq_to_arrays(sol, plot_analytic, denseplot,
108+
plot_vecs,
109+
labels = SciMLBase.diffeq_to_arrays(sol, plot_analytic, denseplot,
109110
plotdensity, tspan, vars, tscale, plotat)
110111

111112
# We must convert from plot Type to symbol here, for plotspec use

src/SciMLBase.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ abstract type AbstractNonlinearProblem{uType, isinplace} <: AbstractDEProblem en
108108
abstract type AbstractIntervalNonlinearProblem{uType, isinplace} <:
109109
AbstractNonlinearProblem{uType,
110110
isinplace} end
111-
const AbstractSteadyStateProblem{uType, isinplace} = AbstractNonlinearProblem{uType,
111+
const AbstractSteadyStateProblem{
112+
uType, isinplace} = AbstractNonlinearProblem{uType,
112113
isinplace}
113114

114115
"""
@@ -373,7 +374,6 @@ abstract type AbstractDiscretization <: AbstractSciMLAlgorithm end
373374
# Discretization metadata
374375
"""
375376
$(TYPEDEF)
376-
377377
"""
378378
abstract type AbstractDiscretizationMetadata{hasTime} end
379379

@@ -566,7 +566,10 @@ abstract type AbstractPDENoTimeSolution{T, N, S, D} <:
566566
"""
567567
$(TYPEDEF)
568568
"""
569-
const AbstractPDESolution{T, N, S, D} = Union{AbstractPDETimeSeriesSolution{T, N, S, D},
569+
const AbstractPDESolution{T,
570+
N,
571+
S,
572+
D} = Union{AbstractPDETimeSeriesSolution{T, N, S, D},
570573
AbstractPDENoTimeSolution{T, N, S, D}}
571574

572575
"""
@@ -628,8 +631,8 @@ abstract type ADOriginator end
628631
"""
629632
$(TYPEDEF)
630633
631-
Used to specify which variables can be aliased in a solve.
632-
Every concrete AbstractAliasSpecifier should have at least the fields `alias_p` and `alias_f`.
634+
Used to specify which variables can be aliased in a solve.
635+
Every concrete AbstractAliasSpecifier should have at least the fields `alias_p` and `alias_f`.
633636
"""
634637
abstract type AbstractAliasSpecifier end
635638

src/callbacks.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,16 +378,15 @@ is constructed by passing the constructor `ContinuousCallback`, `DiscreteCallbac
378378
You can pass as many callbacks as you like. When the solvers encounter multiple
379379
callbacks, the following rules apply:
380380
381-
* `ContinuousCallback`s and `VectorContinuousCallback`s are applied before `DiscreteCallback`s. (This is because
382-
they often implement event-finding that will backtrack the timestep to smaller
383-
than `dt`).
384-
* For `ContinuousCallback`s and `VectorContinuousCallback`s, the event times are found by rootfinding and only
385-
the first `ContinuousCallback` or `VectorContinuousCallback` affect is applied.
386-
* The `DiscreteCallback`s are then applied in order. Note that the ordering only
387-
matters for the conditions: if a previous callback modifies `u` in such a way
388-
that the next callback no longer evaluates condition to `true`, its `affect`
389-
will not be applied.
390-
381+
- `ContinuousCallback`s and `VectorContinuousCallback`s are applied before `DiscreteCallback`s. (This is because
382+
they often implement event-finding that will backtrack the timestep to smaller
383+
than `dt`).
384+
- For `ContinuousCallback`s and `VectorContinuousCallback`s, the event times are found by rootfinding and only
385+
the first `ContinuousCallback` or `VectorContinuousCallback` affect is applied.
386+
- The `DiscreteCallback`s are then applied in order. Note that the ordering only
387+
matters for the conditions: if a previous callback modifies `u` in such a way
388+
that the next callback no longer evaluates condition to `true`, its `affect`
389+
will not be applied.
391390
"""
392391
struct CallbackSet{T1 <: Tuple, T2 <: Tuple} <: DECallback
393392
continuous_callbacks::T1

src/ensemble/basic_ensemble_solve.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ tighten_container_eltype(u) = u
138138
function __solve(prob::EnsembleProblem{<:AbstractVector{<:AbstractSciMLProblem}},
139139
alg::Union{AbstractDEAlgorithm, Nothing},
140140
ensemblealg::BasicEnsembleAlgorithm; kwargs...)
141-
Base.depwarn("This dispatch is deprecated for the standard ensemble syntax. See the Parallel
142-
Ensembles Simulations Interface page for more details", :EnsembleProblemSolve)
141+
Base.depwarn(
142+
"This dispatch is deprecated for the standard ensemble syntax. See the Parallel
143+
Ensembles Simulations Interface page for more details",
144+
:EnsembleProblemSolve)
143145
invoke(__solve, Tuple{AbstractEnsembleProblem, typeof(alg), typeof(ensemblealg)},
144146
prob, alg, ensemblealg; trajectories = length(prob.prob), kwargs...)
145147
end

src/ensemble/ensemble_problems.jl

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Defines a structure to manage an ensemble (batch) of problems.
102102
Each field controls how the ensemble behaves during simulation.
103103
104104
## Arguments
105+
105106
- `prob`: The original base problem to replicate or modify.
106107
- `prob_func`: A function that defines how to generate each subproblem.
107108
- `output_func`: A function to post-process each individual simulation result.
@@ -144,11 +145,14 @@ $(TYPEDEF)
144145
Constructor for deprecated usage where a vector of problems is passed directly.
145146
146147
!!! warning
148+
147149
This constructor is deprecated. Use the standard ensemble syntax with `prob_func` instead.
148150
"""
149151
function EnsembleProblem(prob::AbstractVector{<:AbstractSciMLProblem}; kwargs...)
150-
Base.depwarn("This dispatch is deprecated for the standard ensemble syntax. See the Parallel \
151-
Ensembles Simulations Interface page for more details", :EnsembleProblem)
152+
Base.depwarn(
153+
"This dispatch is deprecated for the standard ensemble syntax. See the Parallel \
154+
Ensembles Simulations Interface page for more details",
155+
:EnsembleProblem)
152156
invoke(EnsembleProblem,
153157
Tuple{Any},
154158
prob;
@@ -163,12 +167,12 @@ Main constructor for `EnsembleProblem`.
163167
164168
## Keyword Arguments
165169
166-
- `prob`: The base problem.
167-
- `prob_func`: Function to modify the base problem per trajectory.
168-
- `output_func`: Function to extract output from a solution.
169-
- `reduction`: Function to aggregate results.
170-
- `u_init`: Initial value for aggregation.
171-
- `safetycopy`: Whether to deepcopy the problem before modifying.
170+
- `prob`: The base problem.
171+
- `prob_func`: Function to modify the base problem per trajectory.
172+
- `output_func`: Function to extract output from a solution.
173+
- `reduction`: Function to aggregate results.
174+
- `u_init`: Initial value for aggregation.
175+
- `safetycopy`: Whether to deepcopy the problem before modifying.
172176
"""
173177
function EnsembleProblem(prob;
174178
prob_func = DEFAULT_PROB_FUNC,
@@ -203,12 +207,15 @@ $(TYPEDEF)
203207
Constructor that is used for NOnlinearProblem.
204208
205209
!!! warning
210+
206211
This dispatch is deprecated. See the Parallel Ensembles Simulations Interface page.
207212
"""
208213
function SciMLBase.EnsembleProblem(
209214
prob::AbstractSciMLProblem, u0s::Vector{Vector{T}}; kwargs...) where {T}
210-
Base.depwarn("This dispatch is deprecated for the standard ensemble syntax. See the Parallel \
211-
Ensembles Simulations Interface page for more details", :EnsembleProblem)
215+
Base.depwarn(
216+
"This dispatch is deprecated for the standard ensemble syntax. See the Parallel \
217+
Ensembles Simulations Interface page for more details",
218+
:EnsembleProblem)
212219
prob_func = (prob, i, repeat = nothing) -> remake(prob, u0 = u0s[i])
213220
return SciMLBase.EnsembleProblem(prob; prob_func, kwargs...)
214221
end
@@ -220,8 +227,8 @@ Defines a weighted version of an `EnsembleProblem`, where different simulations
220227
221228
## Arguments
222229
223-
- `ensembleprob`: The base ensemble problem.
224-
- `weights`: A vector of weights corresponding to each simulation.
230+
- `ensembleprob`: The base ensemble problem.
231+
- `weights`: A vector of weights corresponding to each simulation.
225232
"""
226233
struct WeightedEnsembleProblem{T1 <: AbstractEnsembleProblem, T2 <: AbstractVector} <:
227234
AbstractEnsembleProblem
@@ -251,7 +258,6 @@ end
251258
$(TYPEDEF)
252259
253260
Constructor for `WeightedEnsembleProblem`. Ensures weights sum to 1 and matches problem count.
254-
255261
"""
256262
function WeightedEnsembleProblem(args...; weights, kwargs...)
257263
# TODO: allow skipping checks?
@@ -260,4 +266,3 @@ function WeightedEnsembleProblem(args...; weights, kwargs...)
260266
@assert length(ep.prob) == length(weights)
261267
WeightedEnsembleProblem(ep, weights)
262268
end
263-

src/initialization.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ the `u0` and `p` as-is, and is always successful if it returns. Valid only for
164164
`AbstractDEProblem` and `AbstractDAEProblem`. Requires a `DEIntegrator` as its second argument.
165165
166166
Keyword arguments:
167-
- `abstol`: The absolute value below which the norm of the residual of algebraic equations
168-
should lie. The norm function used is `integrator.opts.internalnorm` if present, and
169-
`LinearAlgebra.norm` if not.
167+
168+
- `abstol`: The absolute value below which the norm of the residual of algebraic equations
169+
should lie. The norm function used is `integrator.opts.internalnorm` if present, and
170+
`LinearAlgebra.norm` if not.
170171
"""
171172
function get_initial_values(
172173
prob::AbstractDEProblem, integrator::DEIntegrator, f, alg::CheckInit,
@@ -219,12 +220,13 @@ If the field is absent or the value is `nothing`, return `u0` and `p` successful
219220
The success value returned depends on the success of the nonlinear solve.
220221
221222
Keyword arguments:
222-
- `nlsolve_alg`: The NonlinearSolve.jl algorithm to use. If not provided, this function will
223-
throw an error.
224-
- `abstol`, `reltol`: The `abstol` (`reltol`) to use for the nonlinear solve. The value
225-
provided to the `OverrideInit` constructor takes priority over this keyword argument.
226-
If the former is `nothing`, this keyword argument will be used. If it is also not provided,
227-
an error will be thrown.
223+
224+
- `nlsolve_alg`: The NonlinearSolve.jl algorithm to use. If not provided, this function will
225+
throw an error.
226+
- `abstol`, `reltol`: The `abstol` (`reltol`) to use for the nonlinear solve. The value
227+
provided to the `OverrideInit` constructor takes priority over this keyword argument.
228+
If the former is `nothing`, this keyword argument will be used. If it is also not provided,
229+
an error will be thrown.
228230
229231
All additional keyword arguments are forwarded to `solve`.
230232

src/remake.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,8 @@ function updated_u0_p(
11201120
return (u0 === missing ? state_values(prob) : u0),
11211121
(p === missing ? parameter_values(prob) : p)
11221122
end
1123-
newu0, newp = _updated_u0_p_internal(
1123+
newu0,
1124+
newp = _updated_u0_p_internal(
11241125
prob, u0, p, t0; interpret_symbolicmap, use_defaults)
11251126
return late_binding_update_u0_p(prob, u0, p, t0, newu0, newp)
11261127
end
@@ -1164,7 +1165,8 @@ function maybe_eager_initialize_problem(prob::AbstractSciMLProblem, initializati
11641165
end
11651166
if initialization_data !== nothing && !lazy_initialization &&
11661167
(!is_time_dependent(prob) || current_time(prob) !== nothing)
1167-
u0, p, _ = get_initial_values(
1168+
u0, p,
1169+
_ = get_initial_values(
11681170
prob, prob, prob.f, OverrideInit(), Val(isinplace(prob)))
11691171
if u0 !== nothing && eltype(u0) == Any && isempty(u0)
11701172
u0 = nothing

0 commit comments

Comments
 (0)