8000 allow sisotool to receive kvect as a singleton rather than always an … · python-control/python-control@3854050 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3854050

Browse files
committed
allow sisotool to receive kvect as a singleton rather than always an array
1 parent 8c764d0 commit 3854050

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

control/sisotool.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .bdalg import append, connect
1010
from .iosys import tf2io, ss2io, summing_junction, interconnect
1111
from control.statesp import _convert_to_statespace, StateSpace
12+
import numpy as np
1213
import matplotlib.pyplot as plt
1314
import warnings
1415

@@ -101,6 +102,9 @@ def sisotool(sys, kvect=None, xlim_rlocus=None, ylim_rlocus=None,
101102
'margins': margins_bode
102103
}
103104

105+
# make sure kvect is an array
106+
if kvect is not None and ~hasattr(kvect, '__len__'):
107+
kvect = np.atleast_1d(kvect)
104108
# First time call to setup the bode and step response plots
105109
_SisotoolUpdate(sys, fig,
106110
1 if kvect is None else kvect[0], bode_plot_params)

control/tests/sisotool_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ def test_sisotool_tvect(self, tsys):
136136
bode_plot_params=dict(), tvect=tvect)
137137
assert_array_almost_equal(tvect, ax_step.lines[0].get_data()[0])
138138

139+
@pytest.mark.skipif(plt.get_current_fig_manager().toolbar is None,
140+
reason="Requires the zoom toolbar")
141+
def test_sisotool_kvect(self, tsys):
142+
# test supply kvect
143+
kvect = np.linspace(0, 1, 10)
144+
# check if it can receive an array
145+
sisotool(tsys, kvect=kvect)
146+
# check if it can receive a singleton
147+
sisotool(tsys, kvect=1)
148+
139149

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

0 commit comments

Comments
 (0)
0