fix gain handling in rlocus and sisotool by sawyerbfuller · Pull Request #809 · python-control/python-control

Added some more fixes to the kvect kwarg in rlocus and sisotool. kvect was intended to let the user specify their own array of gains, but it wasn't being used that way. Two primary changes aim to make it do what I believe was its intended purpose:

  1. I deprecated kvect in sisotool, because you probably don't want to specify your own set of gains to plot in the rlocus plot in sisotool anyway. You probably want to use the ones that are computed automatically. Especially because sisotool/rlocus allows you to zoom in, and it re-computes gain points for the new zoomed root locus plot, to get a more precise click. Instead, there is now a new keyword, initial_gain that allows the user to specify the starting value of the closed-loop gain to plot in its four plots. kvect can be still given, and it reproduces the old behavior of sisotool using kvect[0] as the initial gain, and ignoring everything else in kvect. And there is now a deprecation warning.

  2. For rlocus, you might actually want to specify your own kvect if for example you only want to see where the roots go for a certain set of gains. But this wasn't what was happening: the rlocus plot ignores the kvect argument altogether and essentially always uses its own pre-computed gains. This is because any time the axis range is changed, kvect is automatically recomputed, which is basically every time the plot is created. I fixed it so that the new behavior is that if kvect is supplied to rlocus, it is no longer recomputed automatically if the plot is zoomed.

  3. Other improvements:

  • docstring fixes
  • pep8 cleanups
  • change mymat to root_array in rlocus to better describe its function