Skip to content

Commit 06ecd2e

Browse files
committed
Format
1 parent 6c7e4b8 commit 06ecd2e

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

docs/src/basics/Events.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,14 @@ once our affect function returns. Furthermore, it will check that it is possible
456456

457457
The function given to `ImperativeAffect` needs to have the signature:
458458

459-
```julia
460-
f(modified::NamedTuple, observed::NamedTuple, ctx, integrator)::NamedTuple
459+
```julia
460+
f(modified::NamedTuple, observed::NamedTuple, ctx, integrator)::NamedTuple
461461
```
462+
462463
The function `f` will be called with `observed` and `modified` `NamedTuple`s that are derived from their respective `NamedTuple` definitions.
463464
In our example, if `furnace_on` is `false`, then the value of the `x` that's passed in as `modified` will be `(furnace_on = false)`.
464465
The modified values should be passed out in the same format: to set `furnace_on` to `true` we need to return a tuple `(furnace_on = true)`.
465-
The examples does this with Setfield, recreating the result tuple before returning it; the returned tuple may optionally be missing values as
466+
The examples does this with Setfield, recreating the result tuple before returning it; the returned tuple may optionally be missing values as
466467
well, in which case those values will not be written back to the problem.
467468

468469
Accordingly, we can now interpret the `ImperativeAffect` definitions to mean that when `temp = furnace_off_threshold` we

src/systems/callbacks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ function compile_user_affect(affect::ImperativeAffect, cb, sys, dvs, ps; kwargs.
11351135

11361136
# let the user do their thing
11371137
upd_vals = user_affect(upd_component_array, obs_component_array, ctx, integ)
1138-
1138+
11391139
# write the new values back to the integrator
11401140
_generated_writeback(integ, upd_funs, upd_vals)
11411141

test/symbolic_events.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,8 @@ end
10291029
[temp ~ furnace_off_threshold],
10301030
ModelingToolkit.ImperativeAffect(modified = (; furnace_on)) do x, o, c, i
10311031
@set! x.furnace_on = false
1032-
end; initialize = ModelingToolkit.ImperativeAffect(modified = (; temp)) do x, o, c, i
1032+
end; initialize = ModelingToolkit.ImperativeAffect(modified = (;
1033+
temp)) do x, o, c, i
10331034
@set! x.temp = 0.2
10341035
end)
10351036
furnace_enable = ModelingToolkit.SymbolicContinuousCallback(

0 commit comments

Comments
 (0)