Skip to content

Commit bb1a8a9

Browse files
committed
update spelling, most importantly fix wrong spelling of continuous
1 parent c5d18a6 commit bb1a8a9

File tree

4 files changed

+47
-40
lines changed

4 files changed

+47
-40
lines changed

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# NetworkDynamics Release Notes
22

3+
## v0.10.3 Changelog
4+
- [#301](https://github.com/JuliaDynamics/NetworkDynamics.jl/pull/301) improve callback system performance and flexibility:
5+
- Add callback batching for better DiscreteComponentCallback performance
6+
- Allow `EIndex(1=>2)` as standalone edge index with relaxed type constraints
7+
- Optimize CallbackSet construction to prevent performance bottlenecks
8+
- Add important documentation warning about parameter array copying in callbacks
9+
310
## v0.10.2 Changelog
411
- [#299](https://github.com/JuliaDynamics/NetworkDynamics.jl/pull/299) enhance metadata system with pattern matching and utility functions:
512
- Add String/Regex pattern matching for all metadata functions (`has_metadata`, `get_metadata`, `set_metadata!`, etc.)

docs/src/API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ is_linear_stable
197197
### Define Callbacks
198198
```@docs
199199
NetworkDynamics.ComponentCallback
200-
ContinousComponentCallback
201-
VectorContinousComponentCallback
200+
ContinuousComponentCallback
201+
VectorContinuousComponentCallback
202202
DiscreteComponentCallback
203203
PresetTimeComponentCallback
204204
ComponentCondition

docs/src/callbacks.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ refer to the [Cascading Failure](@ref) example.
2121
## Component-based Callback functions
2222
In practice, events often act locally, meaning they only depend and act on a
2323
specific component or type of component. `NetworkDynamics.jl` provides a way of
24-
defining those callbacks on a component level and automaticially combine them into performant
24+
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

2727
The main entry points are the types [`ContinousComponentCallback`](@ref),
@@ -72,10 +72,10 @@ vectoraffect = ComponentAffect([:u], [:p]) do u, p, event_idx, ctx
7272
end
7373
end
7474
```
75-
Notably, the `syms` (here `:u`) can *exclusivly* refer to "ordinary" states, since they are now writable.
75+
Notably, the `syms` (here `:u`) can *exclusively* refer to "ordinary" states, since they are now writable.
7676
However the affect gets passed a `ctx` "context" object, which is a named tuple which holds additional context like the integrator object, the component model, the index of the component model, the current time and so on. Please refer to the [`ComponentAffect`](@ref) docstring for a detailed list.
7777

78-
Lastly we need to define the actuall callback object using [`ContinousComponentCallback`](@ref)/[`VectorContinousComponentCallback`](@ref):
78+
Lastly we need to define the actual callback object using [`ContinuousComponentCallback`](@ref)/[`VectorContinuousComponentCallback`](@ref):
7979
```julia
8080
ccb = ContinousComponentCallback(condition, affect; kwargs...)
8181
vccb = VectorContinousComponentCallback(condition, affect; kwargs...)
@@ -101,14 +101,14 @@ prob = ODEProblem(nw, uflat(u0), (0,10), pflat(u0); callback=cbs)
101101
sol = solve(prob, ...)
102102
```
103103

104-
When combining the component based callbacks to a single callback, NetworkDynamics will check whether states and or parameters changed during the affect and automaticially call [`SciMLBase.auto_dt_reset!`](@extref) and [`save_parameters!`](@ref) if necessary.
104+
When combining the component based callbacks to a single callback, NetworkDynamics will check whether states and or parameters changed during the affect and automatically call [`SciMLBase.auto_dt_reset!`](@extref) and [`save_parameters!`](@ref) if necessary.
105105

106106

107107
## Normal DiffEq Callbacks
108108
Besides component based callbacks, it is also possible to use "normal" DiffEq
109109
callbacks together with `NetworkDynamics.jl`.
110110
It is far more powerful but also more cumbersome compared to the component based callback functions.
111-
To access states and parameters of specific components, we havily rely on the [Symbolic Indexing](@ref) features.
111+
To access states and parameters of specific components, we heavily rely on the [Symbolic Indexing](@ref) features.
112112

113113
```julia
114114
using SymbolicIndexingInterface as SII
@@ -134,7 +134,7 @@ Please note a few important things here:
134134

135135
```julia
136136
function affect!(integrator, vidx)
137-
p = NWParameter(integrator) # get symbolicially indexable parameter object
137+
p = NWParameter(integrator) # get symbolically indexable parameter object
138138
p.v[vidx, :some_vertex_parameter] = 0 # change some parameter
139139
auto_dt_reset!(integrator)
140140
save_parameters!(integrator)
@@ -159,4 +159,4 @@ Once the `condition` and `affect!` is defined, you can use the [`SciMLBase.Conti
159159
To extract or plot timeseries of observed states under *time variant
160160
parameters* (i.e. parameters that are changed in a callback), those changes
161161
need to be recorded using the [`save_parameters!`](@ref) function whenever `p` is changed.
162-
When using [ComponentCallback](@ref NetworkDynamics.ComponentCallback), NetworkDynamics will automaticially check for changes in `p` and save them if necessary.
162+
When using [ComponentCallback](@ref NetworkDynamics.ComponentCallback), NetworkDynamics will automatically check for changes in `p` and save them if necessary.

src/callbacks.jl

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ bundles a [`ComponentCondition`](@ref) as well as a [`ComponentAffect`](@ref)
66
which can be then tied to a component model using [`add_callback!`](@ref) or
77
[`set_callback!`](@ref).
88
9-
On a Network level, you can automaticially create network wide `CallbackSet`s using
9+
On a Network level, you can automatically create network wide `CallbackSet`s using
1010
[`get_callbacks`](@ref).
1111
1212
See
1313
[`ContinousComponentCallback`](@ref) and [`VectorContinousComponentCallback`](@ref) for concrete
14-
implemenations of this abstract type.
14+
implementations of this abstract type.
1515
"""
1616
abstract type ComponentCallback end
1717

@@ -20,25 +20,25 @@ abstract type ComponentCallback end
2020
2121
Creates a callback condition for a [`ComponentCallback`].
2222
- `f`: The condition function. Must be a function of the form `out=f(u, p, t)`
23-
when used for [`ContinousComponentCallback`](@ref) or
23+
when used for [`ContinuousComponentCallback`](@ref) or
2424
[`DiscreteComponentCallback`](@ref) and `f!(out, u, p, t)` when used for
25-
[`VectorContinousComponentCallback`](@ref).
25+
[`VectorContinuousComponentCallback`](@ref).
2626
- Arguments of `f`
27-
- `u`: The current value of the selecte `sym` states, provided as a [`SymbolicView`](@ref) object.
27+
- `u`: The current value of the selected `sym` states, provided as a [`SymbolicView`](@ref) object.
2828
- `p`: The current value of the selected `psym` parameters.
2929
- `t`: The current simulation time.
3030
- `sym`: A vector or tuple of symbols, which represent **states** (including
3131
inputs, outputs, observed) of the component model. Determines, which states will
32-
be available thorugh parameter `u` in the callback condition function `f`.
33-
- `psym`: A vector or tuple of symbols, which represetn **parameters** of the component mode.
32+
be available through parameter `u` in the callback condition function `f`.
33+
- `psym`: A vector or tuple of symbols, which represent **parameters** of the component mode.
3434
Determines, which parameters will be available in the condition function `f`
3535
3636
# Example
3737
Consider a component model with states `[:u1, :u2]`, inputs `[:i]`, outputs
3838
`[:o]` and parameters `[:p1, :p2]`.
3939
4040
ComponentCondition([:u1, :o], [:p1]) do u, p, t
41-
# access states symbolicially or via int index
41+
# access states symbolically or via int index
4242
u[:u1] == u[1]
4343
u[:o] == u[2]
4444
p[:p1] == p[1]
@@ -63,8 +63,8 @@ Creates a callback condition for a [`ComponentCallback`].
6363
is only available in [`VectorContinousComponentCallback`](@ref).
6464
- Arguments of `f`
6565
- `u`: The current (mutable) value of the selected `sym` states, provided as a [`SymbolicView`](@ref) object.
66-
- `p`: The current (mutalbe) value of the selected `psym` parameters.
67-
- `event_idx`: The current event index, i.e. which `out` element triggerd in case of [`VectorContinousComponentCallback`](@ref).
66+
- `p`: The current (mutable) value of the selected `psym` parameters.
67+
- `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.
6969
- `ctx.model`: a referenc to the ocmponent model
7070
- `ctx.vidx`/`ctx.eidx`: The index of the vertex/edge model.
@@ -73,8 +73,8 @@ Creates a callback condition for a [`ComponentCallback`].
7373
- `ctx.t=ctx.integrator.t`: The current simulation time.
7474
- `sym`: A vector or tuple of symbols, which represent **states** (**excluding**
7575
inputs, outputs, observed) of the component model. Determines, which states will
76-
be available thorugh parameter `u` in the callback condition function `f`.
77-
- `psym`: A vector or tuple of symbols, which represetn **parameters** of the component mode.
76+
be available through parameter `u` in the callback condition function `f`.
77+
- `psym`: A vector or tuple of symbols, which represent **parameters** of the component mode.
7878
Determines, which parameters will be available in the condition function `f`
7979
8080
# Example
@@ -97,36 +97,36 @@ struct ComponentAffect{A,DIM,PDIM}
9797
end
9898

9999
"""
100-
ContinousComponentCallback(condition, affect; kwargs...)
100+
ContinuousComponentCallback(condition, affect; kwargs...)
101101
102-
Connect a [`ComponentCondition`](@ref) and a [`ComponentAffect`)[@ref] to a
103-
continous callback which can be attached to a component model using
102+
Connect a [`ComponentCondition`](@ref) and a [`ComponentAffect`](@ref) to a
103+
continuous callback which can be attached to a component model using
104104
[`add_callback!`](@ref) or [`set_callback!`](@ref).
105105
106106
The `kwargs` will be forwarded to the `VectorContinuousCallback` when the component based
107107
callbacks are collected for the whole network using `get_callbacks`.
108108
[`DiffEq.jl docs`](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/)
109109
for available options.
110110
"""
111-
struct ContinousComponentCallback{C,A,CDIM,CPDIM,ADIM,APDIM} <: ComponentCallback
111+
struct ContinuousComponentCallback{C,A,CDIM,CPDIM,ADIM,APDIM} <: ComponentCallback
112112
condition::ComponentCondition{C,CDIM,CPDIM}
113113
affect::ComponentAffect{A,ADIM,APDIM}
114114
kwargs::NamedTuple
115115
end
116-
function ContinousComponentCallback(condition, affect; kwargs...)
116+
function ContinuousComponentCallback(condition, affect; kwargs...)
117117
if haskey(kwargs, :affect_neg!)
118118
throw(ArgumentError("affect_neg! not supported yet. Please raise issue."))
119119
end
120-
ContinousComponentCallback(condition, affect, NamedTuple(kwargs))
120+
ContinuousComponentCallback(condition, affect, NamedTuple(kwargs))
121121
end
122122

123123
"""
124-
VectorContinousComponentCallback(condition, affect, len; kwargs...)
124+
VectorContinuousComponentCallback(condition, affect, len; kwargs...)
125125
126-
Connect a [`ComponentCondition`](@ref) and a [`ComponentAffect`)[@ref] to a
127-
continous callback which can be attached to a component model using
126+
Connect a [`ComponentCondition`](@ref) and a [`ComponentAffect`](@ref) to a
127+
continuous callback which can be attached to a component model using
128128
[`add_callback!`](@ref) or [`set_callback!`](@ref). This vector version allows
129-
for `condions` which have `len` output dimensions.
129+
for `conditions` which have `len` output dimensions.
130130
The `affect` will be triggered with the additional `event_idx` argument to know in which
131131
dimension the zerocrossing was detected.
132132
@@ -135,13 +135,13 @@ callbacks are collected for the whole network using [`get_callbacks(::Network)`]
135135
[`DiffEq.jl docs`](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/)
136136
for available options.
137137
"""
138-
struct VectorContinousComponentCallback{C,A,CDIM,CPDIM,ADIM,APDIM} <: ComponentCallback
138+
struct VectorContinuousComponentCallback{C,A,CDIM,CPDIM,ADIM,APDIM} <: ComponentCallback
139139
condition::ComponentCondition{C,CDIM,CPDIM}
140140
affect::ComponentAffect{A,ADIM,APDIM}
141141
len::Int
142142
kwargs::NamedTuple
143143
end
144-
function VectorContinousComponentCallback(condition, affect, len; kwargs...)
144+
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
@@ -151,7 +151,7 @@ end
151151
"""
152152
DiscreteComponentCallback(condition, affect; kwargs...)
153153
154-
Connect a [`ComponentCondition`](@ref) and a [`ComponentAffect`)[@ref] to a
154+
Connect a [`ComponentCondition`](@ref) and a [`ComponentAffect`](@ref) to a
155155
discrete callback which can be attached to a component model using
156156
[`add_callback!`](@ref) or [`set_callback!`](@ref).
157157
@@ -175,7 +175,7 @@ end
175175
"""
176176
PresetTimeComponentCallback(ts, affect; kwargs...)
177177
178-
Tirgger a [`ComponentAffect`](@ref) at given timesteps `ts` in discrete
178+
Trigger a [`ComponentAffect`](@ref) at given timesteps `ts` in discrete
179179
callback, which can be attached to a component model using
180180
[`add_callback!`](@ref) or [`set_callback!`](@ref).
181181
@@ -209,21 +209,21 @@ function get_callbacks(nw::Network)
209209
elseif length(cbbs) == 1
210210
return to_callback(only(cbbs))
211211
else
212-
# we split in discrete and continous manually, otherwise the CallbackSet
212+
# we split in discrete and continuous manually, otherwise the CallbackSet
213213
# construction can take forever
214214
discrete_cb = []
215-
continous_cb = []
215+
continuous_cb = []
216216
for batch in cbbs
217217
cb = to_callback(batch)
218218
if cb isa SciMLBase.AbstractContinuousCallback
219-
push!(continous_cb, cb)
219+
push!(continuous_cb, cb)
220220
elseif cb isa SciMLBase.AbstractDiscreteCallback
221221
push!(discrete_cb, cb)
222222
else
223223
error("Unknown callback type, should never be reached. Please report this issue.")
224224
end
225225
end
226-
CallbackSet(Tuple(continous_cb), Tuple(discrete_cb));
226+
CallbackSet(Tuple(continuous_cb), Tuple(discrete_cb));
227227
end
228228
end
229229

@@ -333,7 +333,7 @@ function collect_c_or_a_indices(cw::CallbackWrapper, c_or_a, u_or_p)
333333
end
334334

335335
####
336-
#### wrapping of continous callbacks
336+
#### wrapping of continuous callbacks
337337
####
338338
struct ContinousCallbackWrapper{T<:ComponentCallback,C,ST<:SymbolicIndex} <: CallbackWrapper
339339
nw::Network

0 commit comments

Comments
 (0)