Skip to content

Commit

Permalink
test: test getu with parameter symbols and parameter timeseries
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Mar 8, 2024
1 parent 17f9c7f commit bd17977
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/parameter_indexing_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ end
function Base.getproperty(fs::FakeSolution, s::Symbol)
s === :ps ? ParameterIndexingProxy(fs) : getfield(fs, s)
end
SymbolicIndexingInterface.state_values(fs::FakeSolution) = fs.u
SymbolicIndexingInterface.current_time(fs::FakeSolution) = fs.t
SymbolicIndexingInterface.symbolic_container(fs::FakeSolution) = fs.sys
SymbolicIndexingInterface.parameter_values(fs::FakeSolution) = fs.p[end]
SymbolicIndexingInterface.parameter_values(fs::FakeSolution, i) = fs.p[end][i]
Expand Down Expand Up @@ -149,3 +151,20 @@ for (sym, val, arrval, check_inference) in [
@test get(fs, sub_inds) == arrval[sub_inds]
end
end

ps = fs.p[2:2:end]
avals = getindex.(ps, 1)
bvals = getindex.(ps, 2)
cvals = getindex.(ps, 3)
for (sym, val, arrval) in [
(:a, p[1], avals),
((:b, :c), p[2:3], tuple.(bvals, cvals)),
([:c, :a], p[[3, 1]], vcat.(cvals, avals)),
]
get = getu(sys, sym)
@inferred get(fs)
@test get(fs) == arrval
for i in eachindex(ps)
@test get(fs, i) == arrval[i]
end
end

0 comments on commit bd17977

Please sign in to comment.