Skip to content

Commit 8ec7434

Browse files
committed
handle symbols and nothing in partition
1 parent 1a9b1b2 commit 8ec7434

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/named_systems2.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,16 +957,16 @@ function partition(P::NamedStateSpace; u=Symbol[], y=Symbol[],
957957
# D21 = nothing,
958958
# D22 = nothing,
959959
)
960-
if isempty(w)
960+
if w === nothing || (w isa AbstractArray && isempty(w))
961961
w = setdiff(P.u, u)
962962
end
963-
if isempty(z)
963+
if z === nothing || (z isa AbstractArray && isempty(z))
964964
z = setdiff(P.y, y)
965965
end
966-
if isempty(u)
966+
if u === nothing || (u isa AbstractArray && isempty(u))
967967
u = setdiff(P.u, w)
968968
end
969-
if isempty(y)
969+
if y === nothing || (y isa AbstractArray && isempty(y))
970970
y = setdiff(P.y, z)
971971
end
972972
# u = names2indices(identity.(u), P.u)

test/test_named_systems2.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ s3 = named_ss(G3, x = :x, u = :u, y=:y, z=:z, w=:w)
4444
@test length(s3.y) == 2
4545

4646
s3part = partition(s3, y=:y, z=:z, w=:w, u=:u)
47-
@test s3part == G3
48-
@test performance_mapping(s3part) == s3[:z, :w].sys
47+
@test s3part.sys.sys == G3.sys
48+
@test performance_mapping(s3part).sys == s3[:z, :w].sys
4949

5050
# Test prefix matching
5151
G4 = ControlSystemsBase.ssrand(1,2,3)

0 commit comments

Comments
 (0)