Skip to content

Commit 5a2b67a

Browse files
authored
new function get_states (#143)
* new function `get_states` * also add test * fix location of get_states
1 parent 5131439 commit 5a2b67a

6 files changed

Lines changed: 14 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# v2.7
2+
* New function `get_states` that returns an iterator over states contained in a `parallel_integrator`.
13
# v2.6
24
* Added new `GeneralizedDynamicalSystem` abstract type that is an umbrella term.
35
# v2.5

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 = "2.6.6"
4+
version = "2.7.0"
55

66
[deps]
77
DelayEmbeddings = "5732040d-69e3-5649-938a-b6b4f237613f"

src/DynamicalSystemsBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ include("predefined/famous_systems.jl") # includes both discrete and continuous
2828
export GeneralizedDynamicalSystem, DynamicalSystem
2929
export ContinuousDynamicalSystem, DiscreteDynamicalSystem
3030
export get_rule_for_print, isdiscretetime
31-
export dimension, get_state
31+
export dimension, get_state, get_states
3232
export set_parameter!, trajectory, jacobian
3333
export integrator, tangent_integrator, parallel_integrator
3434
export set_state!, get_state, get_deviations, set_deviations!, current_time

src/core/api_docstrings.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ for tangent integrators.
2828
"""
2929
get_state(integ) = integ.u
3030

31+
"""
32+
get_states(pinteg)
33+
Return an iterator over all contained states in a [`parallel_integrator`](@ref).
34+
"""
35+
get_states(integ) = integ.u
36+
3137
"""
3238
set_state!(integ, u [, i::Int = 1])
3339
Set the state of the integrator to `u`, in the sense of the state of the

src/core/continuous.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ get_state(integ::AbstractODEIntegrator{Alg, IIP, S}, k::Int = 1) where {Alg, IIP
219219
get_state(integ::AbstractODEIntegrator{Alg, IIP, S}, k::Int = 1) where {Alg, IIP, S<:AbstractMatrix} =
220220
view(integ.u, :, k)
221221

222+
get_states(integ::AbstractODEIntegrator{Alg, IIP, S}) where {Alg, IIP, S<:AbstractMatrix} =
223+
eachcol(integ.u)
224+
222225
function set_state!(
223226
integ::AbstractODEIntegrator{Alg, IIP, S}, u::AbstractVector
224227
) where {Alg, IIP, S<:AbstractVector}

test/dynsys_integrators.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ for i in 1:8
7171

7272
# Test parallel integrators
7373
pinteg = parallel_integrator(ds, [copy(INITCOD[sysindx]), copy(INITCOD[sysindx])]; diffeq)
74+
@test length(get_states(pinteg)) == 2
7475
puprev = deepcopy(get_state(pinteg))
7576
step!(pinteg)
7677
@test get_state(pinteg, 1) == get_state(pinteg, 2) == get_state(pinteg)

0 commit comments

Comments
 (0)