Skip to content

Commit 309bf97

Browse files
Merge pull request #322 from AayushSabharwal/as/getu-sol
feat: add support for new `getu`/`setu` in SII
2 parents def2cbd + 2d61006 commit 309bf97

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ StaticArrays = "1.6"
5757
StaticArraysCore = "1.1"
5858
Statistics = "1"
5959
StructArrays = "0.6"
60-
SymbolicIndexingInterface = "0.3.1"
60+
SymbolicIndexingInterface = "0.3.2"
6161
Tables = "1"
6262
Test = "1"
6363
Tracker = "0.2"

src/vector_of_array.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ function DiffEqArray(vec::AbstractVector{VT},
198198
sys)
199199
end
200200

201+
SymbolicIndexingInterface.is_timeseries(::Type{<:AbstractVectorOfArray}) = Timeseries()
202+
SymbolicIndexingInterface.state_values(A::AbstractDiffEqArray) = A.u
203+
SymbolicIndexingInterface.current_time(A::AbstractDiffEqArray) = A.t
201204
SymbolicIndexingInterface.parameter_values(A::AbstractDiffEqArray) = A.p
202205
SymbolicIndexingInterface.symbolic_container(A::AbstractDiffEqArray) = A.sys
203206

test/symbolic_indexing_interface_test.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ dx = DiffEqArray([[f(x), f2(x)] for x in t],
2929
@test_throws Exception dx[:p]
3030
@test_throws Exception dx[[:p, :q]]
3131
@test dx[:t] == t
32+
geta = getu(dx, :a)
33+
get_arr = getu(dx, [:a, :b])
34+
get_tuple = getu(dx, (:a, :b))
35+
@test geta(dx) == dx[1, :]
36+
@test get_arr(dx) == vcat.(dx[1, :], dx[2, :])
37+
@test get_tuple(dx) == tuple.(dx[1, :], dx[2, :])
3238

3339
@test symbolic_container(dx) isa SymbolCache
3440
@test parameter_values(dx) == [1.0, 2.0]

0 commit comments

Comments
 (0)