Skip to content

Commit

Permalink
handle equality between different system types
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Jan 20, 2025
1 parent 5fe8d3b commit 0529c94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/ControlSystemsBase/src/types/TransferFunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ isrational(::TransferFunction) = true
#####################################################################

## EQUALITY ##
function ==(G1::TransferFunction, G2::TransferFunction)
function ==(G1::T, G2::T) where T<:TransferFunction
fields = (:timeevol, :ny, :nu, :matrix)
for field in fields
if getproperty(G1, field) != getproperty(G2, field)
Expand All @@ -115,6 +115,8 @@ function ==(G1::TransferFunction, G2::TransferFunction)
return true
end

==(G1::TransferFunction, G2::TransferFunction) = ==(promote(G1,G2)...)

## Approximate ##
function isapprox(G1::TransferFunction, G2::TransferFunction; kwargs...)
G1, G2 = promote(G1, G2)
Expand Down
2 changes: 1 addition & 1 deletion lib/ControlSystemsBase/test/test_zpk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ k = 0.3
@test eltype(fill(zpk(1,0.005)/zpk(2, 0.005),2)) <: TransferFunction
@test eltype(fill(zpk(1)+1,2)) <: TransferFunction

@test eltype([tf(1,1), zpk(1,1)]) <: TransferFunction
@test eltype([tf(1,1), zpk(1,1)]) <: LTISystem

zpk(tf([1 2; 3 4])) == zpk([1 2; 3 4])

Expand Down

0 comments on commit 0529c94

Please sign in to comment.