Skip to content

Commit 9a137a1

Browse files
committed
improve docstring of set state
1 parent 581255a commit 9a137a1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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.11.1"
4+
version = "3.11.2"
55

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

src/core/dynamicalsystem_interface.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ StateSpaceSets.dimension(ds::DynamicalSystem) = length(current_state(ds))
332332
# API - altering status of the system
333333
###########################################################################################
334334
"""
335-
set_state!(ds::DynamicalSystem, u::AbstractArray{Real})
335+
set_state!(ds::DynamicalSystem, u::AbstractArray{<:Real})
336336
337337
Set the state of `ds` to `u`, which must match dimensionality with that of `ds`.
338338
Also ensure that the change is notified to whatever integration protocol is used.
@@ -383,8 +383,11 @@ end
383383
set_state!(ds::DynamicalSystem, mapping::AbstractDict)
384384
385385
Convenience version of `set_state!` that iteratively calls `set_state!(ds, val, i)`
386-
for all index-value pairs `(i, val)` in `mapping`. This allows you to
387-
partially set only some state variables.
386+
for all index-value pairs `(i, val)` in `mapping`.
387+
This is useful primarily in two cases:
388+
1) to partially set only some state variables,
389+
2) to set variables by name (if the system is created via ModelingToolkit.jl)
390+
so that you don't have to keep track of the order of the dynamic variables.
388391
"""
389392
function set_state!(ds::DynamicalSystem, mapping::AbstractDict)
390393
# ensure we use a mutable vector, so same code works for in-place problems

0 commit comments

Comments
 (0)