Skip to content

Commit 567d298

Browse files
authored
Rename referrenced -> referenced, deprecate old spellings (#257)
Finishes #236 by following the maintainer's review: - Mass-replace the misspelled `referrenced` with `referenced` across src, tests, docs and CHANGELOG, including comments and error messages. - Export `referenced_sciml_prob` (previously unexported despite being part of the public extension API) and add a docstring. - Keep `referrenced_sciml_prob`, `referrenced_sciml_model` and the internal `has_referrenced_model` as deprecated aliases in `src/deprecations.jl`, so downstream code keeps working with a deprecation warning. - Bump version to 3.18.0 and add a changelog entry.
1 parent 884d7f3 commit 567d298

14 files changed

Lines changed: 70 additions & 53 deletions

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v3.18
2+
3+
- The public API functions `referrenced_sciml_prob`, `referrenced_sciml_model`, and the internal `has_referrenced_model` have been renamed to fix the misspelling: `referenced_sciml_prob`, `referenced_sciml_model`, `has_referenced_model`. The misspelled names are kept as deprecated aliases that forward to the new ones, so existing code keeps working but emits a deprecation warning. `referenced_sciml_prob` is now also exported and documented.
4+
15
# v3.17
26

37
- `CoupledSDEs` (along with `diffusion_matrix` and related utilities) is now part of the core package instead of living behind the `StochasticSystemsBase` package extension. Users no longer need to load `StochasticDiffEq` to construct or use `CoupledSDEs`, and `Base.get_extension` is no longer required to access `diffusion_matrix`.
@@ -86,7 +90,7 @@ model and all symbolic variables. Accessing a `DynamicalSystem` using symbolic v
8690
is possible via the functions [`observe_state`](@ref), [`set_state!`](@ref),
8791
[`current_parameter`](@ref) and [`set_parameter!`](@ref).
8892
The referenced MTK model corresponding to the dynamical system can be obtained with
89-
`model = referrenced_sciml_model(ds::DynamicalSystem)`.
93+
`model = referenced_sciml_model(ds::DynamicalSystem)`.
9094

9195
See also the online overarching tutorial for an example.
9296

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DynamicalSystemsBase"
22
uuid = "6e36e845-645a-534a-86f2-f5d4aa5a06b4"
33
repo = "https://github.com/JuliaDynamics/DynamicalSystemsBase.jl.git"
4-
version = "3.17.0"
4+
version = "3.18.0"
55

66
[deps]
77
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ current_time
2929
initial_time
3030
isinplace(::DynamicalSystem)
3131
successful_step
32-
referrenced_sciml_model
32+
referenced_sciml_model
3333
named_variables
3434
```
3535

src/core/dynamicalsystem_interface.jl

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ model and all symbolic variables. Accessing a `DynamicalSystem` using symbolic v
5252
is possible via the functions [`observe_state`](@ref), [`set_state!`](@ref),
5353
[`current_parameter`](@ref) and [`set_parameter!`](@ref).
5454
The referenced MTK model corresponding to the dynamical system can be obtained with
55-
`model = referrenced_sciml_model(ds::DynamicalSystem)`.
55+
`model = referenced_sciml_model(ds::DynamicalSystem)`.
5656
5757
See also the DynamicalSystems.jl tutorial online for an example.
5858
@@ -92,7 +92,7 @@ unless when developing new algorithm implementations that use dynamical systems.
9292
- [`initial_time`](@ref)
9393
- [`isinplace`](@ref)
9494
- [`successful_step`](@ref)
95-
- [`referrenced_sciml_model`](@ref)
95+
- [`referenced_sciml_model`](@ref)
9696
- [`named_variables`](@ref)
9797
9898
### API - alter status
@@ -127,32 +127,40 @@ errormsg(ds) = error("Not yet implemented for dynamical system of type $(nameof(
127127

128128
export current_state, initial_state, current_parameters, current_parameter, initial_parameters, isinplace,
129129
current_time, initial_time, successful_step, isdeterministic, isdiscretetime, dynamic_rule,
130-
reinit!, set_state!, set_parameter!, set_parameters!, step!, observe_state, referrenced_sciml_model, named_variables
130+
reinit!, set_state!, set_parameter!, set_parameters!, step!, observe_state,
131+
referenced_sciml_model, referenced_sciml_prob, named_variables
131132

132133
###########################################################################################
133134
# Symbolic support
134135
###########################################################################################
135-
# Simply extend the `referrenced_sciml_prob` and you have symbolic indexing support!
136+
# Simply extend the `referenced_sciml_prob` and you have symbolic indexing support!
136137
import SymbolicIndexingInterface
137-
referrenced_sciml_prob(::DynamicalSystem) = nothing
138+
"""
139+
referenced_sciml_prob(ds::DynamicalSystem)
140+
141+
Return the SciML problem (e.g. `ODEProblem`, `SDEProblem`) that `ds` was built from,
142+
or `nothing` if `ds` does not reference one. The returned problem is used for symbolic
143+
indexing through SymbolicIndexingInterface.jl.
144+
"""
145+
referenced_sciml_prob(::DynamicalSystem) = nothing
138146

139147
# The rest are all automated!
140148
"""
141-
referrenced_sciml_model(ds::DynamicalSystem)
149+
referenced_sciml_model(ds::DynamicalSystem)
142150
143-
Return the ModelingToolkit.jl structurally-simplified model referrenced by `ds`.
144-
Return `nothing` if there is no referrenced model.
151+
Return the ModelingToolkit.jl structurally-simplified model referenced by `ds`.
152+
Return `nothing` if there is no referenced model.
145153
"""
146-
referrenced_sciml_model(ds::DynamicalSystem) = referrenced_sciml_model(referrenced_sciml_prob(ds))
147-
referrenced_sciml_model(prob::SciMLBase.AbstractDEProblem) = prob.f.sys
148-
referrenced_sciml_model(::Nothing) = nothing
154+
referenced_sciml_model(ds::DynamicalSystem) = referenced_sciml_model(referenced_sciml_prob(ds))
155+
referenced_sciml_model(prob::SciMLBase.AbstractDEProblem) = prob.f.sys
156+
referenced_sciml_model(::Nothing) = nothing
149157

150-
# return true if there is an actual referrenced system
151-
has_referrenced_model(prob::SciMLBase.AbstractDEProblem) = has_referrenced_model(referrenced_sciml_model(prob))
152-
has_referrenced_model(prob::DynamicalSystem) = has_referrenced_model(referrenced_sciml_model(prob))
153-
has_referrenced_model(::Nothing) = false
154-
has_referrenced_model(::SymbolicIndexingInterface.SymbolCache{Nothing, Nothing, Nothing}) = false
155-
has_referrenced_model(sys) = true
158+
# return true if there is an actual referenced system
159+
has_referenced_model(prob::SciMLBase.AbstractDEProblem) = has_referenced_model(referenced_sciml_model(prob))
160+
has_referenced_model(prob::DynamicalSystem) = has_referenced_model(referenced_sciml_model(prob))
161+
has_referenced_model(::Nothing) = false
162+
has_referenced_model(::SymbolicIndexingInterface.SymbolCache{Nothing, Nothing, Nothing}) = false
163+
has_referenced_model(sys) = true
156164

157165
"""
158166
named_variables(ds::DynamicalSystem)
@@ -165,7 +173,7 @@ X = StateSpaceSet(X; names = named_variables(ds))
165173
in downstream functions to name a set coming from `ds` (if possible).
166174
"""
167175
function named_variables(ds::DynamicalSystem)
168-
mtk = referrenced_sciml_model(ds)
176+
mtk = referenced_sciml_model(ds)
169177
isnothing(mtk) && return nothing
170178
return SymbolicIndexingInterface.getname.(SymbolicIndexingInterface.variable_symbols(mtk))
171179
end
@@ -198,7 +206,7 @@ Return the state `u` of `ds` _observed_ at "index" `i`. Possibilities are:
198206
- `i::Int` returns the `i`-th dynamic variable.
199207
- `i::Function` returns `f(current_state(ds))`.
200208
- `i::SymbolLike` returns the value of the corresponding symbolic variable.
201-
This is valid only for dynamical systems referrencing a ModelingToolkit.jl model
209+
This is valid only for dynamical systems referencing a ModelingToolkit.jl model
202210
which also has `i` as one of its listed variables (either uknowns or observed).
203211
Here `i` can be anything can be anything
204212
that could index the solution object `sol = ModelingToolkit.solve(...)`,
@@ -220,16 +228,16 @@ function observe_state(ds::DynamicalSystem, index, u::AbstractArray = current_st
220228
return index(u)
221229
elseif index isa Integer
222230
return u[index]
223-
elseif has_referrenced_model(ds)
224-
prob = referrenced_sciml_prob(ds)
231+
elseif has_referenced_model(ds)
232+
prob = referenced_sciml_prob(ds)
225233
ugetter = SymbolicIndexingInterface.observed(prob, index)
226234
p = current_parameters(ds)
227235
return ugetter(u, p, t)
228236
else
229237
throw(
230238
ArgumentError(
231239
"Invalid index to observe state, or if symbolic index, the " *
232-
"dynamical system does not referrence a ModelingToolkit.jl system."
240+
"dynamical system does not reference a ModelingToolkit.jl system."
233241
)
234242
)
235243
end
@@ -264,8 +272,8 @@ to extract the parameter from, which must match layout with its default value.
264272
Use [`parameter_name`](@ref) for an accompanying name.
265273
"""
266274
function current_parameter(ds::DynamicalSystem, index, p = current_parameters(ds))
267-
prob = referrenced_sciml_prob(ds)
268-
if !has_referrenced_model(prob)
275+
prob = referenced_sciml_prob(ds)
276+
if !has_referenced_model(prob)
269277
return _get_parameter(p, index)
270278
else # symbolic parameter
271279
if !SymbolicIndexingInterface.is_parameter(prob, index)
@@ -389,17 +397,17 @@ function set_state!(ds::DynamicalSystem, value::Real, i)
389397
end
390398

391399
function set_state!(u::AbstractArray, value::Real, i, ds::DynamicalSystem)
392-
prob = referrenced_sciml_prob(ds)
400+
prob = referenced_sciml_prob(ds)
393401
if i isa Integer
394402
u[i] = value
395-
elseif has_referrenced_model(prob)
403+
elseif has_referenced_model(prob)
396404
usetter = SymbolicIndexingInterface.setu(prob, i)
397405
usetter(u, value)
398406
else
399407
throw(
400408
ArgumentError(
401409
"Invalid index to set state, or if symbolic index, the " *
402-
"dynamical system does not referrence a ModelingToolkit.jl system."
410+
"dynamical system does not reference a ModelingToolkit.jl system."
403411
)
404412
)
405413
end
@@ -451,8 +459,8 @@ function set_parameter!(ds::DynamicalSystem, index, value, p = current_parameter
451459
return _set_parameter!(ds::DynamicalSystem, index, value, p)
452460
end
453461
function _set_parameter!(ds::DynamicalSystem, index, value, p = current_parameters(ds))
454-
prob = referrenced_sciml_prob(ds)
455-
if !has_referrenced_model(prob)
462+
prob = referenced_sciml_prob(ds)
463+
if !has_referenced_model(prob)
456464
if p isa Union{AbstractArray, AbstractDict}
457465
setindex!(p, value, index)
458466
else

src/core/trajectory.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Optionally provide a starting state `u0` which is `current_state(ds)` by default
1212
If time evolution diverged or in general failed before `T`,
1313
the remaining of the trajectory is set to the last valid point.
1414
15-
The dimensions of `X` are automatically named if `ds` referrences an MTK model
15+
The dimensions of `X` are automatically named if `ds` references an MTK model
1616
and if `save_idxs` remains at its default value.
1717
1818
## Keyword arguments

src/core_systems/continuous_time_ode.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function CoupledODEs(f, u0, p = SciMLBase.NullParameters(); t0 = 0, diffeq = DEF
8686
prob = ODEProblem{IIP}(f, s, (T(t0), T(Inf)), p)
8787
return CoupledODEs(prob, diffeq)
8888
end
89-
# This preserves the referrenced MTK system and the originally passed diffeq kwargs
89+
# This preserves the referenced MTK system and the originally passed diffeq kwargs
9090
CoupledODEs(ds::CoupledODEs, diffeq) = CoupledODEs(ODEProblem(ds), merge(ds.diffeq, diffeq))
9191
# Below `special_kwargs` is undocumented internal option for passing `internalnorm`
9292
function CoupledODEs(prob::ODEProblem, diffeq = DEFAULT_DIFFEQ; special_kwargs...)
@@ -194,4 +194,4 @@ function set_parameter!(ds::CoupledODEs, args...)
194194
return
195195
end
196196

197-
referrenced_sciml_prob(ds::CoupledODEs) = ds.integ.sol.prob
197+
referenced_sciml_prob(ds::CoupledODEs) = ds.integ.sol.prob

src/core_systems/continuous_time_sde.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function CoupledSDEs(
223223
integ, deepcopy(prob.p), diffeq, noise_type
224224
)
225225
end
226-
# This preserves the referrenced MTK system and the originally passed diffeq kwargs
226+
# This preserves the referenced MTK system and the originally passed diffeq kwargs
227227
CoupledSDEs(ds::CoupledSDEs, diffeq) = CoupledSDEs(SDEProblem(ds), merge(ds.diffeq, diffeq))
228228

229229
"""
@@ -270,7 +270,7 @@ function CoupledSDEs(
270270
noise_process = nothing,
271271
seed = rand(UInt64)
272272
)
273-
prob = referrenced_sciml_prob(ds)
273+
prob = referenced_sciml_prob(ds)
274274
# we want the symbolic jacobian to be transfered over
275275
# dynamic_rule(ds) takes the deepest nested f wich does not have a jac field
276276
return CoupledSDEs(
@@ -288,7 +288,7 @@ deterministic part of `ds`.
288288
function CoupledODEs(
289289
sys::CoupledSDEs; diffeq = DEFAULT_DIFFEQ, t0 = 0.0
290290
)
291-
prob = referrenced_sciml_prob(sys)
291+
prob = referenced_sciml_prob(sys)
292292
# we want the symbolic jacobian to be transfered over
293293
# dynamic_rule(ds) takes the deepest nested f wich does not have a jac field
294294
return CoupledODEs(
@@ -331,7 +331,7 @@ function set_parameter!(ds::CoupledSDEs, args...)
331331
return nothing
332332
end
333333

334-
referrenced_sciml_prob(ds::CoupledSDEs) = ds.integ.sol.prob
334+
referenced_sciml_prob(ds::CoupledSDEs) = ds.integ.sol.prob
335335

336336
"""
337337
diffusion_matrix(ds::CoupledSDEs)
@@ -479,7 +479,7 @@ function diffusion_function(g, IIP, noise_prototype)
479479
end
480480

481481
function diffusion_function(ds::CoupledSDEs{IIP}) where {IIP}
482-
prob = referrenced_sciml_prob(ds)
482+
prob = referenced_sciml_prob(ds)
483483
return diffusion_function(prob.g, IIP, prob.noise_rate_prototype)
484484
end
485485

src/core_systems/jacobian.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ function jacobian(ds::CoreDynamicalSystem{IIP}) where {IIP}
2323
if ds isa ContinuousTimeDynamicalSystem
2424
# TODO: This is the correct API way to obtain the Jacobian,
2525
# however it relies on MTK dependency, so we can't do it.
26-
# if has_referrenced_model(ds)
27-
# model = referrenced_sciml_model(ds)
26+
# if has_referenced_model(ds)
27+
# model = referenced_sciml_model(ds)
2828
# Joop, Jiip = generate_jacobian(model; expression = Val{false})
2929
# if IIP
3030
# jac = Jiip
3131
# else
3232
# jac = Joop
3333
# end
3434
# end
35-
prob = referrenced_sciml_prob(ds)
35+
prob = referenced_sciml_prob(ds)
3636
if prob.f isa SciMLBase.AbstractDiffEqFunction && !isnothing(prob.f.jac)
3737
jac = prob.f.jac
3838
else

src/deprecations.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
@deprecate get_state current_state
22
@deprecate get_deviations current_deviations
33

4+
# Misspelled names kept for backwards compatibility; remove in a future breaking release.
5+
@deprecate referrenced_sciml_prob referenced_sciml_prob
6+
@deprecate referrenced_sciml_model referenced_sciml_model
7+
@deprecate has_referrenced_model has_referenced_model false
8+
49
export integrator, tangent_integrator, parallel_integrator, poincaremap
510
export projected_integrator
611

src/derived_systems/parallel_systems.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function ParallelDynamicalSystem(ds::CoreDynamicalSystem, states::Vector{<:Abstr
6363
pds = CoupledODEs(prob, ds.diffeq; internalnorm = inorm)
6464
end
6565
M = ds isa CoupledODEs && isinplace(ds)
66-
prob = referrenced_sciml_prob(ds)
66+
prob = referenced_sciml_prob(ds)
6767
return ParallelDynamicalSystemAnalytic{typeof(pds), M}(pds, dynamic_rule(ds), prob)
6868
end
6969

@@ -76,7 +76,7 @@ function ParallelDynamicalSystem(smap::StroboscopicMap, states)
7676
pds = StroboscopicMap(cont_pds, smap.period)
7777

7878
M = smap.ds isa CoupledODEs && isinplace(smap.ds)
79-
prob = referrenced_sciml_prob(smap.ds)
79+
prob = referenced_sciml_prob(smap.ds)
8080
return ParallelDynamicalSystemAnalytic{typeof(pds), M}(pds, dynamic_rule(smap), prob)
8181
end
8282

@@ -148,7 +148,7 @@ end
148148
(pdsa::ParallelDynamicalSystemAnalytic)(t::Real, i::Int = 1) = pdsa.ds(t)[i]
149149
dynamic_rule(pdsa::ParallelDynamicalSystemAnalytic) = pdsa.original_f
150150

151-
referrenced_sciml_prob(pdsa::ParallelDynamicalSystemAnalytic) = pdsa.prob
151+
referenced_sciml_prob(pdsa::ParallelDynamicalSystemAnalytic) = pdsa.prob
152152

153153
function observe_state(ds::ParallelDynamicalSystemAnalytic, index, i::Int = 1)
154154
u = current_state(ds, i)
@@ -221,7 +221,7 @@ end
221221

222222
for f in (
223223
:current_time, :initial_time, :isdiscretetime,
224-
:current_parameters, :initial_parameters, :dynamic_rule, :referrenced_sciml_model,
224+
:current_parameters, :initial_parameters, :dynamic_rule, :referenced_sciml_model,
225225
)
226226
@eval $(f)(pdtds::PDTDS, args...; kw...) = $(f)(pdtds.systems[1], args...; kw...)
227227
end

0 commit comments

Comments
 (0)