Skip to content

Commit

Permalink
handle identical types
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Jan 20, 2025
1 parent 732cabe commit 5fe8d3b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/ControlSystemsBase/src/connections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ function Base.vect(X::LTISystem...)
LTISystem[X...]
end

function Base.vect(X::T...) where T <: LTISystem
T[X...]
end

"""
add_input(sys::AbstractStateSpace, B2::AbstractArray, D2 = 0)
Expand Down
8 changes: 7 additions & 1 deletion lib/ControlSystemsBase/src/types/StateSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,13 @@ end
## Approximate ##
function isapprox(sys1::ST1, sys2::ST2; kwargs...) where {ST1<:AbstractStateSpace,ST2<:AbstractStateSpace}
fieldnames(ST1) == fieldnames(ST2) || (return false)
return all(isapprox(getfield(sys1, f), getfield(sys2, f); kwargs...) for f in fieldnames(ST1))
return all(fieldnames(ST1)) do f
if fieldtype(ST1, f) <: Union{Number, AbstractArray{<:Number}, LTISystem}
isapprox(getfield(sys1, f), getfield(sys2, f); kwargs...)
else
getfield(sys1, f) == getfield(sys2, f)
end
end
end

## ADDITION ##
Expand Down
4 changes: 4 additions & 0 deletions lib/ControlSystemsBase/test/test_connections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ v = [ssrand(1,1,1), tf(1)]
@test v[1] isa StateSpace{Continuous, Float64}
@test v[2] isa TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}

# Test vector creation
v = [tf(1), tf(1)]
@test v isa Vector{TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}}

# Combination tfRational and sisoZpk
Czpk_111 = zpk([-2],[-5],1)
Czpk_211 = zpk([-1+sqrt(2)im,-1-sqrt(2)im], [-5,-3],1)
Expand Down

0 comments on commit 5fe8d3b

Please sign in to comment.