Skip to content

Commit cd7faaa

Browse files
committed
fixed unit test code
1 parent ffd7b5f commit cd7faaa

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

control/sisotool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ def pid_designer(plant, gain='P', sign=+1, input_signal='r',
258258
Feedforward controller. If :class:`LTI`, must have timebase that is
259259
compatible with plant.
260260
"""
261+
261262
plant = _convert_to_statespace(plant)
262263
if plant.ninputs == 1:
263264
plant = ss2io(plant, inputs='u', outputs='y')

control/tests/lti_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_damp(self):
7777
p2_splane = -wn2 * zeta2 + 1j * wn2 * np.sqrt(1 - zeta2**2)
7878
p2_zplane = np.exp(p2_splane * dt)
7979
np.testing.assert_almost_equal(p2, p2_zplane)
80-
80+
8181
def test_dcgain(self):
8282
sys = tf(84, [1, 2])
8383
np.testing.assert_allclose(sys.dcgain(), 42)
@@ -136,7 +136,7 @@ def test_common_timebase(self, dt1, dt2, expected, sys1, sys2):
136136
(0, 1),
137137
(1, 2)])
138138
def test_common_timebase_errors(self, i1, i2):
139-
"""Test that common_timbase throws errors on invalid combinations"""
139+
"""Test that common_timbase raises errors on invalid combinations"""
140140
with pytest.raises(ValueError):
141141
common_timebase(i1, i2)
142142
# Make sure behaviour is symmetric

control/tests/sisotool_test.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,25 @@ def test_sisotool_mimo(self, sys222, sys221):
143143

144144
@pytest.mark.usefixtures("mplcleanup")
145145
class TestPidDesigner:
146-
syscont = TransferFunction(1,[1, 3, 0])
147-
sysdisc1 = c2d(TransferFunction(1,[1, 3, 0]), .1)
148-
syscont221 = StateSpace([[-.3, 0],[1,0]],[[-1,],[.1,]], [0, -.3], 0)
146+
@pytest.fixture
147+
def plant(self, request):
148+
plants = {
149+
'syscont':TransferFunction(1,[1, 3, 0]),
150+
'sysdisc1':c2d(TransferFunction(1,[1, 3, 0]), .1),
151+
'syscont221':StateSpace([[-.3, 0],[1,0]],[[-1,],[.1,]], [0, -.3], 0)}
152+
return plants[request.param]
149153

150154
# cont or discrete, vary P I or D
151-
@pytest.mark.parametrize('plant', (syscont, sysdisc1))
155+
# @pytest.mark.parametrize('plant', (syscont, sysdisc1))
156+
@pytest.mark.parametrize('plant', ('syscont', 'sysdisc1'), indirect=True)
152157
@pytest.mark.parametrize('gain', ('P', 'I', 'D'))
153158
@pytest.mark.parametrize("kwargs", [{'Kp0':0.01},])
154159
def test_pid_designer_1(self, plant, gain, kwargs):
155160
pid_designer(plant, gain, **kwargs)
156161

157162
# input from reference or disturbance
158-
@pytest.mark.parametrize('plant', (syscont, syscont221))
163+
@pytest.mark.parametrize('plant', ('syscont', 'syscont221'), indirect=True)
164+
# @pytest.mark.parametrize('plant', (syscont, syscont221))
159165
@pytest.mark.parametrize("kwargs", [
160166
{'input_signal':'r', 'Kp0':0.01, 'derivative_in_feedback_path':True},
161167
{'input_signal':'d', 'Kp0':0.01, 'derivative_in_feedback_path':True},])

0 commit comments

Comments
 (0)