Skip to content

Commit 25d52da

Browse files
test: test indexing of Initials portion
1 parent 84f7309 commit 25d52da

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/split_parameters.jl

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using DataInterpolations
55
using BlockArrays: BlockedArray
66
using ModelingToolkit: t_nounits as t, D_nounits as D
77
using ModelingToolkit: MTKParameters, ParameterIndex, NONNUMERIC_PORTION
8-
using SciMLStructures: Tunable, Discrete, Constants
8+
using SciMLStructures: Tunable, Discrete, Constants, Initials
99
using StaticArrays: SizedVector
1010
using SymbolicIndexingInterface: is_parameter, getp
1111

@@ -204,7 +204,7 @@ connections = [[state_feedback.input.u[i] ~ model_outputs[i] for i in 1:4]
204204
S = get_sensitivity(closed_loop, :u)
205205

206206
@testset "Indexing MTKParameters with ParameterIndex" begin
207-
ps = MTKParameters(collect(1.0:10.0),
207+
ps = MTKParameters(collect(1.0:10.0), collect(11.0:20.0),
208208
(BlockedArray([true, false, false, true], [2, 2]),
209209
BlockedArray([[1 2; 3 4], [2 4; 6 8]], [1, 1])),
210210
# (BlockedArray([[true, false], [false, true]]), BlockedArray([[[1 2; 3 4]], [[2 4; 6 8]]])),
@@ -213,6 +213,9 @@ S = get_sensitivity(closed_loop, :u)
213213
@test ps[ParameterIndex(Tunable(), 1)] == 1.0
214214
@test ps[ParameterIndex(Tunable(), 2:4)] == collect(2.0:4.0)
215215
@test ps[ParameterIndex(Tunable(), reshape(4:7, 2, 2))] == reshape(4.0:7.0, 2, 2)
216+
@test ps[ParameterIndex(Initials(), 1)] == 11.0
217+
@test ps[ParameterIndex(Initials(), 2:4)] == collect(12.0:14.0)
218+
@test ps[ParameterIndex(Initials(), reshape(4:7, 2, 2))] == reshape(14.0:17.0, 2, 2)
216219
@test ps[ParameterIndex(Discrete(), (2, 1, 2, 2))] == 4
217220
@test ps[ParameterIndex(Discrete(), (2, 2))] == [2 4; 6 8]
218221
@test ps[ParameterIndex(Constants(), (1, 1))] == 5
@@ -221,8 +224,12 @@ S = get_sensitivity(closed_loop, :u)
221224
ps[ParameterIndex(Tunable(), 1)] = 1.5
222225
ps[ParameterIndex(Tunable(), 2:4)] = [2.5, 3.5, 4.5]
223226
ps[ParameterIndex(Tunable(), reshape(5:8, 2, 2))] = [5.5 7.5; 6.5 8.5]
227+
ps[ParameterIndex(Initials(), 1)] = 11.5
228+
ps[ParameterIndex(Initials(), 2:4)] = [12.5, 13.5, 14.5]
229+
ps[ParameterIndex(Initials(), reshape(5:8, 2, 2))] = [15.5 17.5; 16.5 18.5]
224230
ps[ParameterIndex(Discrete(), (2, 1, 2, 2))] = 5
225231
@test ps[ParameterIndex(Tunable(), 1:8)] == collect(1.0:8.0) .+ 0.5
232+
@test ps[ParameterIndex(Initials(), 1:8)] == collect(11.0:18.0) .+ 0.5
226233
@test ps[ParameterIndex(Discrete(), (2, 1, 2, 2))] == 5
227234
end
228235

0 commit comments

Comments
 (0)