diff --git a/lib/ControlSystemsBase/src/ControlSystemsBase.jl b/lib/ControlSystemsBase/src/ControlSystemsBase.jl index 6d523e39c..ee1e61bb1 100644 --- a/lib/ControlSystemsBase/src/ControlSystemsBase.jl +++ b/lib/ControlSystemsBase/src/ControlSystemsBase.jl @@ -244,7 +244,7 @@ function __init__() print(io, " for automatic discretization (applicable to systems without delays or nonlinearities only).") end plots_id = Base.PkgId(UUID("91a5bcdd-55d7-5caf-9e0b-520d859cae80"), "Plots") - if exc.f !== nothing && nameof(exc.f) === :plot && parentmodule(argtypes[1]) == @__MODULE__() && !haskey(Base.loaded_modules, plots_id) + if exc.f isa Function && nameof(exc.f) === :plot && parentmodule(argtypes[1]) == @__MODULE__() && !haskey(Base.loaded_modules, plots_id) printstyled(io, "\nPlotting is not available unless Plots.jl is loaded manually. Call `using Plots` before plotting.", color=:green, bold=true) elseif (exc.f == /) && argtypes[2] <: DelayLtiSystem print(io, "A delayed system can not be inverted. Consider use of the function `feedback`.") diff --git a/lib/ControlSystemsBase/src/analysis.jl b/lib/ControlSystemsBase/src/analysis.jl index 388df85a3..568303188 100644 --- a/lib/ControlSystemsBase/src/analysis.jl +++ b/lib/ControlSystemsBase/src/analysis.jl @@ -506,7 +506,7 @@ function sisomargin(sys::LTISystem, w::AbstractVector{<:Real}; full=false, allMa if !allMargins #Only output the smallest margins gm, idx = findmin([gm;Inf]) wgm = [wgm;NaN][idx] - pm, idx = findmin([abs.(pm);Inf]) + pm, idx = findmin([pm;Inf]) fi = [fi;NaN][idx] wpm = [wpm;NaN][idx] if full diff --git a/lib/ControlSystemsBase/src/connections.jl b/lib/ControlSystemsBase/src/connections.jl index b002214c5..b2478a5bf 100644 --- a/lib/ControlSystemsBase/src/connections.jl +++ b/lib/ControlSystemsBase/src/connections.jl @@ -140,12 +140,12 @@ Base.typed_hcat(::Type{S}, X::Union{AbstractArray{<:Number,1}, AbstractArray{<:N ## Mixed-type array creation # When creating an array of systems, an error may be thrown if the default Base.vect is called that tries to promote all systems to a common type. E.g., when using non-proper transfer functions and statespace systems. We thus opt out of the conversion with the method below -function Base.vect(X::LTISystem...) - LTISystem[X...] +function Base.vect(X0::LTISystem, X::LTISystem...) + LTISystem[X0, X...] end -function Base.vect(X::T...) where T <: LTISystem - T[X...] +function Base.vect(X0::T, X::T...) where T <: LTISystem + T[X0, X...] end """ diff --git a/lib/ControlSystemsBase/test/runtests.jl b/lib/ControlSystemsBase/test/runtests.jl index f41ebec5e..8d1ecdfe1 100644 --- a/lib/ControlSystemsBase/test/runtests.jl +++ b/lib/ControlSystemsBase/test/runtests.jl @@ -4,13 +4,13 @@ import Base.isapprox # In framework and test_synthesis import SparseArrays: sparse # In test_matrix_comps import Polynomials: conv # In test_conversion and test_synthesis using Aqua -# @testset "Aqua" begin -# Aqua.test_all(ControlSystemsBase; -# ambiguities = false, # causes 100s of hits in all dependencies -# stale_deps = true, # Aqua complains about itself https://github.com/JuliaTesting/Aqua.jl/issues/78 -# project_toml_formatting = false, # https://github.com/JuliaTesting/Aqua.jl/issues/105 -# ) -# end +@testset "Aqua" begin + Aqua.test_all(ControlSystemsBase; + ambiguities = false, # causes 100s of hits in all dependencies + stale_deps = true, # Aqua complains about itself https://github.com/JuliaTesting/Aqua.jl/issues/78 + project_toml_formatting = false, # https://github.com/JuliaTesting/Aqua.jl/issues/105 + ) +end include("framework.jl") diff --git a/lib/ControlSystemsBase/test/test_analysis.jl b/lib/ControlSystemsBase/test/test_analysis.jl index 23cd6951b..f21a1dbe1 100644 --- a/lib/ControlSystemsBase/test/test_analysis.jl +++ b/lib/ControlSystemsBase/test/test_analysis.jl @@ -245,6 +245,10 @@ Lw = freqresp(L, m[1][])[] @test imag(Lw) ≈ 0 atol = 1e-6 # Test definition of gain margin @test inv(-real(Lw)) ≈ m[2][] atol = 1e-6 # Test definition of gain margin +# https://github.com/JuliaControl/ControlSystems.jl/issues/961 +P = tf(1,[5, 10.25, 6.25, 1]) +w_180, gm, w_c, pm = margin(50P) +@test pm[] ≈ -35.1 rtol=1e-2 # RGA a = 10