Skip to content

Commit d69e9a5

Browse files
committed
fix spelling mistakes
1 parent bb1a8a9 commit d69e9a5

File tree

12 files changed

+60
-52
lines changed

12 files changed

+60
-52
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Allow `EIndex(1=>2)` as standalone edge index with relaxed type constraints
77
- Optimize CallbackSet construction to prevent performance bottlenecks
88
- Add important documentation warning about parameter array copying in callbacks
9+
- **Fixed spelling**: `ContinousComponentCallback``ContinuousComponentCallback` and `VectorContinousComponentCallback``VectorContinuousComponentCallback` (old names maintained as deprecated aliases for backward compatibility)
910

1011
## v0.10.2 Changelog
1112
- [#299](https://github.com/JuliaDynamics/NetworkDynamics.jl/pull/299) enhance metadata system with pattern matching and utility functions:

NetworkDynamicsInspector/test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function get_sol(;limit=1.0)
4444
@info "Trip line $(ctx.eidx) between $(ctx.src) and $(ctx.dst) at t=$(ctx.t)"
4545
p[:active] = 0
4646
end
47-
cb = ContinousComponentCallback(cond, affect)
47+
cb = ContinuousComponentCallback(cond, affect)
4848
set_callback!.(ls, Ref(cb))
4949

5050
tripfirst = PresetTimeComponentCallback(1.0, affect) # reuse the same affect

docs/examples/cascading_failure.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ affect = ComponentAffect([], [:K]) do u, p, ctx
108108
println("Line $(ctx.eidx) tripped at t=$(ctx.integrator.t)")
109109
p[:K] = 0
110110
end
111-
edge_cb = ContinousComponentCallback(cond, affect)
111+
edge_cb = ContinuousComponentCallback(cond, affect)
112112
#=
113113
To enable the callback in simulation, we need to attach them to the individual
114114
edgemodels/vertexmodels.
@@ -155,14 +155,14 @@ plot(sol; idxs=eidxs(sol, :, :P))
155155
## System wide Callbacks
156156
157157
The above solution relies on the `ComponentCallback` features of
158-
NetworkDyanmics. The "low-level" API would be to use `VectorContinousCallback`
158+
NetworkDynamics. The "low-level" API would be to use `VectorContinuousCallback`
159159
and `PresetTimeCallback` directly to achieve the same effect, essentially doing
160160
manually what [`get_callbacks(::Network)`](@ref) is doing for us.
161161
162-
While not necessary in this case, this method offers more flexiblity then the
163-
component based appraoch.
162+
While not necessary in this case, this method offers more flexibility than the
163+
component based approach.
164164
165-
In order to implement the line failures, we need to create a `VectorContinousCallback`.
165+
In order to implement the line failures, we need to create a `VectorContinuousCallback`.
166166
In the callback, we compare the current flow on the line with the limit. If the limit is reached,
167167
the coupling `K` is set to 0.
168168

docs/src/callbacks.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ specific component or type of component. `NetworkDynamics.jl` provides a way of
2424
defining those callbacks on a component level and automatically combine them into performant
2525
[`VectorContinuousCallback`](@extref SciMLBase.VectorContinuousCallback) and [`DiscreteCallback`](@extref SciMLBase.DiscreteCallback) for the whole network.
2626

27-
The main entry points are the types [`ContinousComponentCallback`](@ref),
28-
[`VectorContinousComponentCallback`](@ref) and [`DiscreteComponentCallback`](@ref). All of those objects combine a [`ComponentCondition`](@ref) with an [`ComponentAffect`](@ref).
27+
The main entry points are the types [`ContinuousComponentCallback`](@ref),
28+
[`VectorContinuousComponentCallback`](@ref) and [`DiscreteComponentCallback`](@ref). All of those objects combine a [`ComponentCondition`](@ref) with an [`ComponentAffect`](@ref).
2929

30-
The "normal" [`ContinousComponentCallback`](@ref) and [`DiscreteComponentCallback`](@ref) have a condition which returns a single value. The corresponding affect is triggered when the return value hits zero.
30+
The "normal" [`ContinuousComponentCallback`](@ref) and [`DiscreteComponentCallback`](@ref) have a condition which returns a single value. The corresponding affect is triggered when the return value hits zero.
3131
In contrast, the "vector" version has an in-place condition which writes `len` outputs. When any of those outputs hits zero, the affect is triggered with an additional argument `event_idx` which tells the effect which dimension encountered the zerocrossing.
3232

3333
There is a special type [`PresetTimeComponentCallback`](@ref) which has no explicit condition and triggers the affect at given times.
@@ -43,7 +43,7 @@ condition = ComponentCond([:x, :y], [:p1, :p2]) do u, p, t
4343
return some_condition(u[:x], u[:y], ...)
4444
end
4545
```
46-
In case of a `VectorContinousComponentCallback`, the function signature looks slightly different:
46+
In case of a `VectorContinuousComponentCallback`, the function signature looks slightly different:
4747
```julia
4848
vectorcondition = ComponentCond([:x, :y], [:p1, :p2]) do out, u, p, t
4949
out[1] = some_condition(u[...], p[...])
@@ -77,8 +77,8 @@ However the affect gets passed a `ctx` "context" object, which is a named tuple
7777

7878
Lastly we need to define the actual callback object using [`ContinuousComponentCallback`](@ref)/[`VectorContinuousComponentCallback`](@ref):
7979
```julia
80-
ccb = ContinousComponentCallback(condition, affect; kwargs...)
81-
vccb = VectorContinousComponentCallback(condition, affect; kwargs...)
80+
ccb = ContinuousComponentCallback(condition, affect; kwargs...)
81+
vccb = VectorContinuousComponentCallback(condition, affect; kwargs...)
8282
```
8383
where the `kwargs` are passed to the underlying [`SciMLBase.VectorContinuousCallback`](@extref) to finetune the zerocrossing-detection.
8484

docs/src/inspector.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ First, we need to define the system we want to inspect.
4646
@info "Trip line $(ctx.eidx) between $(ctx.src) and $(ctx.dst) at t=$(ctx.t)"
4747
p[:active] = 0
4848
end
49-
cb = ContinousComponentCallback(cond, affect)
49+
cb = ContinuousComponentCallback(cond, affect)
5050
set_callback!.(ls, Ref(cb))
5151

5252
tripfirst = PresetTimeComponentCallback(1.0, affect) # reuse the same affect

src/NetworkDynamics.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export variable_symbols, parameter_symbols
6969
include("symbolicindexing.jl")
7070

7171
export ComponentCondition, ComponentAffect
72+
# Export deprecated aliases (constants defined at bottom of callbacks.jl)
7273
export ContinousComponentCallback, VectorContinousComponentCallback
7374
export DiscreteComponentCallback, PresetTimeComponentCallback
7475
export SymbolicView

src/callbacks.jl

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ On a Network level, you can automatically create network wide `CallbackSet`s usi
1010
[`get_callbacks`](@ref).
1111
1212
See
13-
[`ContinousComponentCallback`](@ref) and [`VectorContinousComponentCallback`](@ref) for concrete
13+
[`ContinuousComponentCallback`](@ref) and [`VectorContinuousComponentCallback`](@ref) for concrete
1414
implementations of this abstract type.
1515
"""
1616
abstract type ComponentCallback end
@@ -60,13 +60,13 @@ end
6060
6161
Creates a callback condition for a [`ComponentCallback`].
6262
- `f`: The affect function. Must be a function of the form `f(u, p, [event_idx], ctx)` where `event_idx`
63-
is only available in [`VectorContinousComponentCallback`](@ref).
63+
is only available in [`VectorContinuousComponentCallback`](@ref).
6464
- Arguments of `f`
6565
- `u`: The current (mutable) value of the selected `sym` states, provided as a [`SymbolicView`](@ref) object.
6666
- `p`: The current (mutable) value of the selected `psym` parameters.
6767
- `event_idx`: The current event index, i.e. which `out` element triggered in case of [`VectorContinuousComponentCallback`](@ref).
6868
- `ctx::NamedTuple` a named tuple with context variables.
69-
- `ctx.model`: a referenc to the ocmponent model
69+
- `ctx.model`: a reference to the component model
7070
- `ctx.vidx`/`ctx.eidx`: The index of the vertex/edge model.
7171
- `ctx.src`/`ctx.dst`: src and dst indices (only for edge models).
7272
- `ctx.integrator`: The integrator object. Use [`extract_nw`](@ref) to obtain the network.
@@ -145,7 +145,7 @@ function VectorContinuousComponentCallback(condition, affect, len; kwargs...)
145145
if haskey(kwargs, :affect_neg!)
146146
throw(ArgumentError("affect_neg! not supported yet. Please raise issue."))
147147
end
148-
VectorContinousComponentCallback(condition, affect, len, NamedTuple(kwargs))
148+
VectorContinuousComponentCallback(condition, affect, len, NamedTuple(kwargs))
149149
end
150150

151151
"""
@@ -254,8 +254,8 @@ function wrap_component_callbacks(nw)
254254
for typeidx in idx_per_type
255255
batchcomps = components[typeidx]
256256
batchcbs = callbacks[typeidx]
257-
if first(batchcbs) isa Union{ContinousComponentCallback, VectorContinousComponentCallback}
258-
cb = ContinousCallbackWrapper(nw, batchcomps, batchcbs)
257+
if first(batchcbs) isa Union{ContinuousComponentCallback, VectorContinuousComponentCallback}
258+
cb = ContinuousCallbackWrapper(nw, batchcomps, batchcbs)
259259
elseif first(batchcbs) isa DiscreteComponentCallback
260260
cb = DiscreteCallbackWrapper(nw, batchcomps, batchcbs)
261261
elseif first(batchcbs) isa PresetTimeComponentCallback
@@ -270,12 +270,12 @@ function wrap_component_callbacks(nw)
270270
return batches
271271
end
272272
_batchequal(a, b) = false
273-
function _batchequal(a::ContinousComponentCallback, b::ContinousComponentCallback)
273+
function _batchequal(a::ContinuousComponentCallback, b::ContinuousComponentCallback)
274274
_batchequal(a.condition, b.condition) || return false
275275
_batchequal(a.kwargs, b.kwargs) || return false
276276
return true
277277
end
278-
function _batchequal(a::VectorContinousComponentCallback, b::VectorContinousComponentCallback)
278+
function _batchequal(a::VectorContinuousComponentCallback, b::VectorContinuousComponentCallback)
279279
_batchequal(a.condition, b.condition) || return false
280280
_batchequal(a.kwargs, b.kwargs) || return false
281281
a.len == b.len || return false
@@ -335,40 +335,40 @@ end
335335
####
336336
#### wrapping of continuous callbacks
337337
####
338-
struct ContinousCallbackWrapper{T<:ComponentCallback,C,ST<:SymbolicIndex} <: CallbackWrapper
338+
struct ContinuousCallbackWrapper{T<:ComponentCallback,C,ST<:SymbolicIndex} <: CallbackWrapper
339339
nw::Network
340340
components::Vector{ST}
341341
callbacks::Vector{T}
342342
sublen::Int # length of each callback
343343
condition::C
344344
end
345-
function ContinousCallbackWrapper(nw, components, callbacks)
345+
function ContinuousCallbackWrapper(nw, components, callbacks)
346346
if !isconcretetype(eltype(components))
347347
components = [c for c in components]
348348
end
349349
if !isconcretetype(eltype(callbacks))
350350
callbacks = [cb for cb in callbacks]
351351
end
352-
sublen = eltype(callbacks) <: ContinousComponentCallback ? 1 : first(callbacks).len
352+
sublen = eltype(callbacks) <: ContinuousComponentCallback ? 1 : first(callbacks).len
353353
condition = first(callbacks).condition.f
354-
ContinousCallbackWrapper(nw, components, callbacks, sublen, condition)
354+
ContinuousCallbackWrapper(nw, components, callbacks, sublen, condition)
355355
end
356356

357357
# Continuous-specific functions (for vector callbacks)
358-
condition_outrange(ccw::ContinousCallbackWrapper, i) = (1 + (i-1)*ccw.sublen) : i*ccw.sublen
358+
condition_outrange(ccw::ContinuousCallbackWrapper, i) = (1 + (i-1)*ccw.sublen) : i*ccw.sublen
359359

360-
cbidx_from_outidx(ccw::ContinousCallbackWrapper, outidx) = div(outidx-1, ccw.sublen) + 1
361-
subidx_from_outidx(ccw::ContinousCallbackWrapper, outidx) = mod(outidx, 1:ccw.sublen)
360+
cbidx_from_outidx(ccw::ContinuousCallbackWrapper, outidx) = div(outidx-1, ccw.sublen) + 1
361+
subidx_from_outidx(ccw::ContinuousCallbackWrapper, outidx) = mod(outidx, 1:ccw.sublen)
362362

363-
# generate VectorContinuousCallback from a ContinousCallbackWrapper
364-
function to_callback(ccw::ContinousCallbackWrapper)
363+
# generate VectorContinuousCallback from a ContinuousCallbackWrapper
364+
function to_callback(ccw::ContinuousCallbackWrapper)
365365
kwargs = first(ccw.callbacks).kwargs
366366
cond = _batch_condition(ccw)
367367
affect = _batch_affect(ccw)
368368
len = ccw.sublen * length(ccw.callbacks)
369369
VectorContinuousCallback(cond, affect, len; kwargs...)
370370
end
371-
function _batch_condition(ccw::ContinousCallbackWrapper)
371+
function _batch_condition(ccw::ContinuousCallbackWrapper)
372372
usymidxs = collect_c_or_a_indices(ccw, :condition, :sym)
373373
psymidxs = collect_c_or_a_indices(ccw, :condition, :psym)
374374
ucache = DiffCache(zeros(length(usymidxs)), 12)
@@ -396,10 +396,10 @@ function _batch_condition(ccw::ContinousCallbackWrapper)
396396
pv = view(integrator.p, pidxsv)
397397
_p = SymbolicView(pv, ccw.callbacks[i].condition.psym)
398398

399-
if cbtype(ccw) <: ContinousComponentCallback
399+
if cbtype(ccw) <: ContinuousComponentCallback
400400
oidx = only(condition_outrange(ccw, i))
401401
out[oidx] = ccw.condition(_u, _p, t)
402-
elseif cbtype(ccw) <: VectorContinousComponentCallback
402+
elseif cbtype(ccw) <: VectorContinuousComponentCallback
403403
@views _out = out[condition_outrange(ccw, i)]
404404
ccw.condition(_out, _u, _p, t)
405405
else
@@ -409,7 +409,7 @@ function _batch_condition(ccw::ContinousCallbackWrapper)
409409
nothing
410410
end
411411
end
412-
function _batch_affect(ccw::ContinousCallbackWrapper)
412+
function _batch_affect(ccw::ContinuousCallbackWrapper)
413413
usymidxs = collect_c_or_a_indices(ccw, :affect, :sym)
414414
psymidxs = collect_c_or_a_indices(ccw, :affect, :psym)
415415

@@ -449,9 +449,9 @@ function _batch_affect(ccw::ContinousCallbackWrapper)
449449

450450
uhash = hash(uv)
451451
phash = hash(pv)
452-
if cbtype(ccw) <: ContinousComponentCallback
452+
if cbtype(ccw) <: ContinuousComponentCallback
453453
ccw.callbacks[i].affect.f(_u, _p, ctx)
454-
elseif cbtype(ccw) <: VectorContinousComponentCallback
454+
elseif cbtype(ccw) <: VectorContinuousComponentCallback
455455
num = subidx_from_outidx(ccw, outidx)
456456
ccw.callbacks[i].affect.f(_u, _p, num, ctx)
457457
else
@@ -710,3 +710,9 @@ function assert_cb_compat(comp::ComponentModel, cb)
710710
end
711711
cb
712712
end
713+
714+
####
715+
#### Backward compatibility aliases for old misspellings (deprecated)
716+
####
717+
const ContinousComponentCallback = ContinuousComponentCallback
718+
const VectorContinousComponentCallback = VectorContinuousComponentCallback

src/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ function Base.show(io::IO, ::MIME"text/plain", @nospecialize(cb::ComponentCallba
443443
print(io, basename)
444444
print(io, "(")
445445
print(io, shortrepr(cb))
446-
if cb isa VectorContinousComponentCallback
446+
if cb isa VectorContinuousComponentCallback
447447
print(io, ", len=", cb.len)
448448
end
449449
print(io, ")")

test/callbacks_test.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function basenetwork()
3030
nw
3131
end
3232

33-
@testset "continous callback batch tests" begin
33+
@testset "continuous callback batch tests" begin
3434
nw = basenetwork()
3535

3636
tript = Float64[]
@@ -44,7 +44,7 @@ end
4444
push!(tripi, ctx.eidx)
4545
p[:active] = 0
4646
end
47-
cb = ContinousComponentCallback(cond, affect)
47+
cb = ContinuousComponentCallback(cond, affect)
4848
set_callback!.(nw.im.edgem, Ref(cb))
4949

5050
batches = NetworkDynamics.wrap_component_callbacks(nw);
@@ -110,12 +110,12 @@ end
110110

111111
cond = ComponentCondition(identity, [, ], [])
112112
affect = ComponentAffect(identity, [, ],[])
113-
cb = VectorContinousComponentCallback(cond, affect, 2)
113+
cb = VectorContinuousComponentCallback(cond, affect, 2)
114114
add_callback!(v, cb)
115115
display(v)
116116
cond = ComponentCondition(identity, [], [])
117117
affect = ComponentAffect(identity, [],[:M])
118-
cb2 = ContinousComponentCallback(cond, affect)
118+
cb2 = ContinuousComponentCallback(cond, affect)
119119
add_callback!(v, cb2)
120120
display(v)
121121
display(nw)
@@ -138,7 +138,7 @@ end
138138
push!(events, (;θ=u[], ω=u[], t=ctx.t, vidx=ctx.vidx, event_idx=event_idx))
139139
@info "Triggered event_idx $event_idx t=$(ctx.t) on $(ctx.vidx)"
140140
end
141-
ccb = VectorContinousComponentCallback(cond, affect, 2)
141+
ccb = VectorContinuousComponentCallback(cond, affect, 2)
142142
set_callback!(nw.im.vertexm[1], ccb)
143143
set_callback!(nw.im.vertexm[2], ccb)
144144

@@ -199,7 +199,7 @@ end
199199
# invalid obs in affect u
200200
cond = ComponentCondition((args...)->nothing, [:P, :₋P, :srcθ, :limit], [:limit, :K])
201201
affect = ComponentAffect((args...)->nothing, [:₋P],[:active])
202-
cb = ContinousComponentCallback(cond, affect)
202+
cb = ContinuousComponentCallback(cond, affect)
203203
set_callback!.(nw.im.edgem, Ref(cb); check=false);
204204
cbb = only(NetworkDynamics.wrap_component_callbacks(nw));
205205
# oserved can handle parameters now!
@@ -209,7 +209,7 @@ end
209209
# invalid state in condition p
210210
cond = ComponentCondition((args...)->nothing, [:P, :₋P, :srcθ], [:limit, :K, :P])
211211
affect = ComponentAffect((args...)->nothing, [],[:active, :₋P])
212-
cb = ContinousComponentCallback(cond, affect)
212+
cb = ContinuousComponentCallback(cond, affect)
213213
set_callback!.(nw.im.edgem, Ref(cb); check=false);
214214
cbb = only(NetworkDynamics.wrap_component_callbacks(nw));
215215
@test_throws ArgumentError NetworkDynamics._batch_condition(cbb)
@@ -218,19 +218,19 @@ end
218218
# test on set_callback
219219
cond = ComponentCondition((args...)->nothing, [:P, :₋P, :srcθ, :limit], [:limit, :K])
220220
affect = ComponentAffect((args...)->nothing, [],[:active])
221-
cb = ContinousComponentCallback(cond, affect)
221+
cb = ContinuousComponentCallback(cond, affect)
222222
@test_throws ArgumentError set_callback!(nw.im.edgem[1], cb)
223223
cond = ComponentCondition((args...)->nothing, [:P, :₋P, :srcθ], [:limit, :K, :P])
224224
affect = ComponentAffect((args...)->nothing, [],[:active])
225-
cb = ContinousComponentCallback(cond, affect)
225+
cb = ContinuousComponentCallback(cond, affect)
226226
@test_throws ArgumentError set_callback!(nw.im.edgem[1], cb)
227227
cond = ComponentCondition((args...)->nothing, [:P, :₋P, :srcθ], [:limit, :K])
228228
affect = ComponentAffect((args...)->nothing, [:₋P],[:active])
229-
cb = ContinousComponentCallback(cond, affect)
229+
cb = ContinuousComponentCallback(cond, affect)
230230
@test_throws ArgumentError set_callback!(nw.im.edgem[1], cb)
231231
cond = ComponentCondition((args...)->nothing, [:P, :₋P, :srcθ], [:limit, :K])
232232
affect = ComponentAffect((args...)->nothing, [],[:active, :P])
233-
cb = ContinousComponentCallback(cond, affect)
233+
cb = ContinuousComponentCallback(cond, affect)
234234
@test_throws ArgumentError set_callback!(nw.im.edgem[1], cb)
235235
end
236236

test/metadata_test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,15 @@ end
214214
@test get_marker(nw, VIndex(1)) == :circle
215215

216216
# Test callbacks
217-
cb = ContinousComponentCallback(
217+
cb = ContinuousComponentCallback(
218218
ComponentCondition(nothing, [], []),
219219
ComponentAffect(nothing, [], [])
220220
)
221221
set_callback!(nw, VIndex(1), cb)
222222
@test has_callback(nw, VIndex(1))
223223
@test get_callbacks(nw, VIndex(1)) == (cb,)
224224

225-
cb2 = ContinousComponentCallback(
225+
cb2 = ContinuousComponentCallback(
226226
ComponentCondition(nothing, [], []),
227227
ComponentAffect(nothing, [], [])
228228
)

0 commit comments

Comments
 (0)