Skip to content

Commit 7cf9ae5

Browse files
authored
Merge pull request #124 from JuliaControl/overspec
handle specification of both `z` and `y`
2 parents de2084d + e249fd4 commit 7cf9ae5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/named_systems2.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,8 @@ end
864864

865865
names2indices(::Colon, allnames) = 1:length(allnames)
866866

867+
names2indices(inds::Union{Integer, AbstractVector{<:Int}}, allnames) = inds
868+
867869
function names2indices(names, allnames)
868870
inds = Union{Nothing, Int}[findfirst(==(n), allnames) for n in names]
869871
snames = string.(allnames)
@@ -980,6 +982,10 @@ function partition(P::NamedStateSpace; u=nothing, y=nothing,
980982
y = setdiff(1:P.ny, inds)
981983
z = inds
982984
end
985+
u = names2indices(identity.(u), P.u)
986+
y = names2indices(identity.(y), P.y)
987+
z = names2indices(identity.(z), P.y)
988+
w = names2indices(identity.(w), P.u)
983989
u = vcat(u)
984990
y = vcat(y)
985991
z = vcat(z)

test/test_named_systems2.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ s3 = named_ss(G3, x = :x, u = :u, y=:y, z=:z, w=:w)
4343
@test length(s3.u) == 3
4444
@test length(s3.y) == 2
4545

46+
s3part = partition(s3, y=:y, z=:z, w=:w, u=:u)
47+
@test s3part == G3
48+
@test performance_mapping(s3part) == s3[:z, :w].sys
49+
4650
# Test prefix matching
4751
G4 = ControlSystemsBase.ssrand(1,2,3)
4852
s4 = named_ss(G4, x = :x, u = [:u1, :u2], y=[:y])

0 commit comments

Comments
 (0)