Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
allow sisotool to receive kvect as a singleton rather than always an …
…array
  • Loading branch information
sawyerbfuller committed Dec 7, 2022
commit 385405086bc0010e634c77b877240814c4bd11b7
4 changes: 4 additions & 0 deletions control/sisotool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .bdalg import append, connect
from .iosys import tf2io, ss2io, summing_junction, interconnect
from control.statesp import _convert_to_statespace, StateSpace
import numpy as np
import matplotlib.pyplot as plt
import warnings

Expand Down Expand Up @@ -101,6 +102,9 @@ def sisotool(sys, kvect=None, xlim_rlocus=None, ylim_rlocus=None,
'margins': margins_bode
}

# make sure kvect is an array
if kvect is not None and ~hasattr(kvect, '__len__'):
kvect = np.atleast_1d(kvect)
# First time call to setup the bode and step response plots
_SisotoolUpdate(sys, fig,
1 if kvect is None else kvect[0], bode_plot_params)
Expand Down
10 changes: 10 additions & 0 deletions control/tests/sisotool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ def test_sisotool_tvect(self, tsys):
bode_plot_params=dict(), tvect=tvect)
assert_array_almost_equal(tvect, ax_step.lines[0].get_data()[0])

@pytest.mark.skipif(plt.get_current_fig_manager().toolbar is None,
reason="Requires the zoom toolbar")
def test_sisotool_kvect(self, tsys):
# test supply kvect
kvect = np.linspace(0, 1, 10)
# check if it can receive an array
sisotool(tsys, kvect=kvect)
# check if it can receive a singleton
sisotool(tsys, kvect=1)


def test_sisotool_mimo(self, sys222, sys221):
# a 2x2 should not raise an error:
Expand Down