ControlSystems bug?

I use Julia v. 1.2 on 64bit Windows 10, v. v0.5.3 of package ControlSystems.

Consider the following simple system – is there anything wrong in what I do?:

julia> using ControlSystems
julia> A = [-1. -2.; 0 -2]; B=[2.; 1]; C=[1. 0]; D=0.0;
julia> sys=ss(A,B,C,D)
StateSpace{Float64,Array{Float64,2}}
A =
 -1.0  -2.0
  0.0  -2.0
B =
 2.0
 1.0
C =
 1.0  0.0
D =
 0.0

Continuous-time state-space model

julia> tf(sys)
TransferFunction{ControlSystems.SisoRational{Float64}}
Error showing value of type TransferFunction{ControlSystems.SisoRational{Float64}}:
ERROR: MethodError: no method matching printsign(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Float64, ::Int64, ::Bool, ::MIME{Symbol("text/plain")})
Closest candidates are:
  printsign(::IO, ::T, ::Any, ::Any) where T at C:\Users\user_name\.julia\packages\Polynomials\i0ynH\src\show.jl:126
Stacktrace:
 [1] showterm2(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Polynomials.Poly{Float64}, ::Int64, ::Bool, ::Symbol, ::MIME{Symbol("text/plain")}) at C:\Users\user_name\.julia\packages\ControlSystems\pipUm\src\types\SisoTfTypes\polyprint.jl:34
 [2] printpoly2(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Polynomials.Poly{Float64}, ::Symbol, ::MIME{Symbol("text/plain")}) at C:\Users\user_name\.julia\packages\ControlSystems\pipUm\src\types\SisoTfTypes\polyprint.jl:19
 [3] printpolydesc at C:\Users\user_name\.julia\packages\ControlSystems\pipUm\src\types\SisoTfTypes\polyprint.jl:9 [inlined]
 [4] #7 at C:\Users\user_name\.julia\packages\ControlSystems\pipUm\src\types\SisoTfTypes\polyprint.jl:2 [inlined] (repeats 2 times)
 [5] #sprint#342(::Nothing, ::Int64, ::typeof(sprint), ::Function, ::Polynomials.Poly{Float64}) at .\strings\io.jl:107
 [6] sprint at .\strings\io.jl:103 [inlined]
 [7] print_siso(::IOContext{REPL.Terminals.TTYTerminal}, ::ControlSystems.SisoRational{Float64}, ::Symbol) at C:\Users\user_name\.julia\packages\ControlSystems\pipUm\src\types\SisoTfTypes\SisoRational.jl:47
 [8] show(::IOContext{REPL.Terminals.TTYTerminal}, ::TransferFunction{ControlSystems.SisoRational{Float64}}) at C:\Users\user_name\.julia\packages\ControlSystems\pipUm\src\types\TransferFunction.jl:191
 [9] show(::IOContext{REPL.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::TransferFunction{ControlSystems.SisoRational{Float64}}) at .\multimedia.jl:47
 [10] display(::REPL.REPLDisplay, ::MIME{Symbol("text/plain")}, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\REPL\src\REPL.jl:132
 [11] display(::REPL.REPLDisplay, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\REPL\src\REPL.jl:136
 [12] display(::Any) at .\multimedia.jl:323
 [13] #invokelatest#1 at .\essentials.jl:790 [inlined]
 [14] invokelatest at .\essentials.jl:789 [inlined]
 [15] print_response(::IO, ::Any, ::Bool, ::Bool, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\REPL\src\REPL.jl:156
 [16] print_response(::REPL.AbstractREPL, ::Any, ::Bool, ::Bool) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\REPL\src\REPL.jl:141
 [17] (::getfield(REPL, Symbol("#do_respond#38")){Bool,getfield(REPL, Symbol("##48#57")){REPL.LineEditREPL,REPL.REPLHistoryProvider},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\REPL\src\REPL.jl:718
 [18] #invokelatest#1 at .\essentials.jl:790 [inlined]
 [19] invokelatest at .\essentials.jl:789 [inlined]
 [20] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\REPL\src\LineEdit.jl:2306
 [21] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\REPL\src\REPL.jl:1038
 [22] run_repl(::REPL.AbstractREPL, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.2\REPL\src\REPL.jl:201
 [23] (::getfield(Base, Symbol("##737#739")){Bool,Bool,Bool,Bool})(::Module) at .\client.jl:390
 [24] #invokelatest#1 at .\essentials.jl:790 [inlined]
 [25] invokelatest at .\essentials.jl:789 [inlined]
 [26] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at .\client.jl:374
 [27] exec_options(::Base.JLOptions) at .\client.
1 Like

Yeah, there’s an issue and PR open at the moment, it’s due to a change in Polynomials.jl. It’s only related to the display of the transfer function so you can keep using it without printing it until the fix is merged.

1 Like

Thanks for quick answer. OK – I planned to use it in a demo tomorrow. I’ll do a Bode plot instead.

If you look at the pr on the repo you’ll see that it’s an extremely easy fix, you can just fix it locally and use your original demo idea

1 Like

Ah. Good :slight_smile:

Hi! Was the fix merged? I downloaded the package yesterday and looks like the bug is there. Also I can’t find the PR with the fix :frowning:

It should be merged, do you need to do pkg update? Was the latest tagged release of Controlsystems.jl installed or an old version?

1 Like

I updated the version and it worked on v0.5.4!
Thank you very much! :slight_smile:

1 Like

On my computer, the latest version of ControlSystems.jl is v0.5.3 – and I just updated Julia.

With v0.5.3, and transfer functions are not printed – I get the same error message. Could some other package “hold back” the upgrade? I’m on Julia v.1.3, and here is the status list:

julia> Pkg.status()
    Status `C:\Users\user_name\.julia\environments\v1.3\Project.toml`
  [c52e3926] Atom v0.11.3
  [6e4b80f9] BenchmarkTools v0.4.3
  [a134a8b2] BlackBoxOptim v0.5.0
  [336ed68f] CSV v0.5.18
  [861a8166] Combinatorics v1.0.0
  [34da2185] Compat v2.2.0
  [a6e380b2] ControlSystems v0.5.3
  [a93c6f00] DataFrames v0.20.0
  [82cc6244] DataInterpolations v1.3.1
  [864edb3b] DataStructures v0.17.6
  [0c46a032] DifferentialEquations v6.9.0
  [31c24e10] Distributions v0.21.11
  [c87230d0] FFMPEG v0.2.4
  [587475ba] Flux v0.10.0
  [59287772] Formatting v0.4.1
  [f6369f11] ForwardDiff v0.10.7
  [38e38edf] GLM v1.3.5
  [28b8d3ca] GR v0.44.0
  [a2cc645c] GraphPlot v0.3.1
  [9fb69e20] Hiccup v0.2.2
  [7073ff75] IJulia v1.20.2
  [d1acc4aa] IntervalArithmetic v0.16.1
  [138f1668] IntervalConstraintProgramming v0.12.0
  [d2bf35a9] IntervalRootFinding v0.4.0
  [e5e0dc1b] Juno v0.7.2
  [b964fa9f] LaTeXStrings v1.0.3
  [984bce1d] LambertW v0.4.3
  [23fbe1c1] Latexify v0.12.3
  [093fc24a] LightGraphs v1.3.0
  [9c8b4983] LightXML v0.8.1
  [6f286f6a] MultivariateStats v0.7.0
  [2774e3e8] NLsolve v4.2.0
  [0f4fe800] OMJulia v0.1.0 #master (https://github.com/OpenModelica/OMJulia.jl)
  [ab2f91bb] OSQP v0.6.0
  [429524aa] Optim v0.19.7
  [91a5bcdd] Plots v0.28.3
  [f27b6e38] Polynomials v0.6.0
  [08abe8d2] PrettyTables v0.7.0
  [c46f51b8] ProfileView v0.5.1
  [438e738f] PyCall v1.91.2
  [d330b81b] PyPlot v2.8.2
  [37e2e3b7] ReverseDiff v0.3.1
  [90137ffa] StaticArrays v0.12.1
  [2913bbd2] StatsBase v0.32.0
  [c3572dad] Sundials v3.8.1
  [24249f21] SymPy v1.0.10
  [b8865327] UnicodePlots v1.1.0
  [c2297ded] ZMQ v1.0.0
  [9abbd945] Profile
  [9a3f8284] Random

Hard to tell from this, but you can try and figure this out by doing ] add ControlSystems@0.5.4

1 Like

Then you have some package that is holding Controlsystems.jl back from updating. Try adding Controlsystems.jl in a new environment to verify that you get 0.5.4

1 Like

I removed ControlSystems, then did ] add ControlSystgems@0.5.4. That gave the following error message:

v1.3) pkg> add ControlSystems@0.5.4
 Resolving package versions...
ERROR: Unsatisfiable requirements detected for package Plots [91a5bcdd]:
 Plots [91a5bcdd] log:
 ├─possible versions are: [0.12.1-0.12.4, 0.13.0-0.13.1, 0.14.0-0.14.2, 0.15.0-0.15.1, 0.16.0, 0.17.0-0.17.4, 0.18.0, 0.19.0-0.19.3, 0.20.0-0.20.6, 0.21.0, 0.22.0-0.22.5, 0.23.0-0.23.2, 0.24.0, 0.25.0-0.25.3, 0.26.0-0.26.3, 0.27.0-0.27.1, 0.28.0-0.28.3] or uninstalled
 ├─restricted to versions 0.28.3 by an explicit requirement, leaving only versions 0.28.3
 └─restricted by compatibility requirements with ControlSystems [a6e380b2] to versions: [0.24.0, 0.25.0-0.25.3, 0.26.0-0.26.3, 0.27.0-0.27.1] — no versions left
   └─ControlSystems [a6e380b2] log:
     ├─possible versions are: 0.5.0-0.5.4 or uninstalled
     └─restricted to versions 0.5.4 by an explicit requirement, leaving only versions 0.5.4

I do have Plots v0.28.3 installed. If I read the error message correctly, ControlSystems doesn’t work with Plots version later than v0.27.1???

So – is my interpretation correct?

  • ControlSystems only works with Plots up to and including v0.27.1?
  • Some other package requires a newer version of Plots, so Julia doesn’t downgrade Plots??

Yep that’s correct. Controlsystems.jl probably works with new Plots.jl but the compact has not been updated yet.

1 Like

Over the last few weeks I ran into many of these cases. Not sure if it helps, but these are some of my remedies (more for feedback).

One option you could try is to run ControlSystems as a project. Almost all work I do with Julia these days is as projects. A second option, that I try to stay away from, is forking a package.

This is a reasonable ‘simple’ case as ControlSystems’ Project.toml likely directly specifies this constraint ( [compat] entry), but I’ve seen many more ‘lurking package versions’ creating this situations, e.g. with SpecialFunctions, BinDeps & Homebrew, Combinatorics to name a few.

I think right now, with still so many packages carrying a major version of 0, the problem is more prevalent. If I understand it correctly if in this case Plots would have been 1.0.0 and ControlSystems’ [compat] entry Plots = "1.0" it would have worked.

It certainly would help if those across the board packages like Plots, DataFrames, Distributions, Documenter, etc. could be upgraded to v1 level. Also will slow down CompatHelper a bit :slight_smile:

Just some thoughts, YMMV.