Skip to content

Commit c1bdce7

Browse files
committed
handle identical types
1 parent 732cabe commit c1bdce7

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lib/ControlSystemsBase/src/connections.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ function Base.vect(X::LTISystem...)
144144
LTISystem[X...]
145145
end
146146

147+
function Base.vect(X::T...) where T <: LTISystem
148+
T[X...]
149+
end
150+
151+
function Base.vect(X::TransferFunction...)
152+
TransferFunction[X...]
153+
end
154+
147155

148156
"""
149157
add_input(sys::AbstractStateSpace, B2::AbstractArray, D2 = 0)

lib/ControlSystemsBase/src/types/StateSpace.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,13 @@ end
248248
## Approximate ##
249249
function isapprox(sys1::ST1, sys2::ST2; kwargs...) where {ST1<:AbstractStateSpace,ST2<:AbstractStateSpace}
250250
fieldnames(ST1) == fieldnames(ST2) || (return false)
251-
return all(isapprox(getfield(sys1, f), getfield(sys2, f); kwargs...) for f in fieldnames(ST1))
251+
return all(fieldnames(ST1)) do f
252+
if fieldtype(ST1, f) <: Union{Number, AbstractArray{<:Number}, LTISystem}
253+
isapprox(getfield(sys1, f), getfield(sys2, f); kwargs...)
254+
else
255+
getfield(sys1, f) == getfield(sys2, f)
256+
end
257+
end
252258
end
253259

254260
## ADDITION ##

lib/ControlSystemsBase/test/test_connections.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ v = [ssrand(1,1,1), tf(1)]
154154
@test v[1] isa StateSpace{Continuous, Float64}
155155
@test v[2] isa TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
156156

157+
# Test vector creation
158+
v = [tf(1), tf(1)]
159+
@test v isa Vector{TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}}
160+
157161
# Combination tfRational and sisoZpk
158162
Czpk_111 = zpk([-2],[-5],1)
159163
Czpk_211 = zpk([-1+sqrt(2)im,-1-sqrt(2)im], [-5,-3],1)

0 commit comments

Comments
 (0)