Skip to content

Commit 2082796

Browse files
committed
make iosys_test.py compatible with current source code state
revert this commit when merging into or with python-control#400 and python-control#431
1 parent 514d1a0 commit 2082796

1 file changed

Lines changed: 35 additions & 39 deletions

File tree

control/tests/iosys_test.py

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ class TSys:
2929
"""Return some test systems"""
3030
# Create a single input/single output linear system
3131
T.siso_linsys = ct.StateSpace(
32-
[[-1, 1], [0, -2]], [[0], [1]], [[1, 0]], [[0]])
32+
[[-1, 1], [0, -2]], [[0], [1]], [[1, 0]], [[0]], 0)
3333

3434
# Create a multi input/multi output linear system
3535
T.mimo_linsys1 = ct.StateSpace(
3636
[[-1, 1], [0, -2]], [[1, 0], [0, 1]],
37-
[[1, 0], [0, 1]], np.zeros((2, 2)))
37+
[[1, 0], [0, 1]], np.zeros((2, 2)), 0)
3838

3939
# Create a multi input/multi output linear system
4040
T.mimo_linsys2 = ct.StateSpace(
4141
[[-1, 1], [0, -2]], [[0, 1], [1, 0]],
42-
[[1, 0], [0, 1]], np.zeros((2, 2)))
42+
[[1, 0], [0, 1]], np.zeros((2, 2)), 0)
4343

4444
# Create simulation parameters
4545
T.T = np.linspace(0, 10, 100)
@@ -281,7 +281,7 @@ def test_algebraic_loop(self, tsys):
281281
linsys = tsys.siso_linsys
282282
lnios = ios.LinearIOSystem(linsys)
283283
nlios = ios.NonlinearIOSystem(None, \
284-
lambda t, x, u, params: u*u, inputs=1, outputs=1)
284+
lambda t, x, u, params: u*u, inputs=1, outputs=1, dt=0)
285285
nlios1 = nlios.copy()
286286
nlios2 = nlios.copy()
287287

@@ -310,7 +310,7 @@ def test_algebraic_loop(self, tsys):
310310
iosys = ios.InterconnectedSystem(
311311
(lnios, nlios), # linear system w/ nonlinear feedback
312312
((1,), # feedback interconnection (sig to 0)
313-
(0, (1, 0, -1))),
313+
(0, (1, 0, -1))),
314314
0, # input to linear system
315315
0 # output from linear system
316316
)
@@ -331,7 +331,7 @@ def test_algebraic_loop(self, tsys):
331331

332332
# Algebraic loop due to feedthrough term
333333
linsys = ct.StateSpace(
334-
[[-1, 1], [0, -2]], [[0], [1]], [[1, 0]], [[1]])
334+
[[-1, 1], [0, -2]], [[0], [1]], [[1, 0]], [[1]], 0)
335335
lnios = ios.LinearIOSystem(linsys)
336336
iosys = ios.InterconnectedSystem(
337337
(nlios, lnios), # linear system w/ nonlinear feedback
@@ -374,7 +374,7 @@ def test_rmul(self, tsys):
374374
# Also creates a nested interconnected system
375375
ioslin = ios.LinearIOSystem(tsys.siso_linsys)
376376
nlios = ios.NonlinearIOSystem(None, \
377-
lambda t, x, u, params: u*u, inputs=1, outputs=1)
377+
lambda t, x, u, params: u*u, inputs=1, outputs=1, dt=0)
378378
sys1 = nlios * ioslin
379379
sys2 = ios.InputOutputSystem.__rmul__(nlios, sys1)
380380

@@ -414,7 +414,7 @@ def test_feedback(self, tsys):
414414
# Linear system with constant feedback (via "nonlinear" mapping)
415415
ioslin = ios.LinearIOSystem(tsys.siso_linsys)
416416
nlios = ios.NonlinearIOSystem(None, \
417-
lambda t, x, u, params: u, inputs=1, outputs=1)
417+
lambda t, x, u, params: u, inputs=1, outputs=1, dt=0)
418418
iosys = ct.feedback(ioslin, nlios)
419419
linsys = ct.feedback(tsys.siso_linsys, 1)
420420

@@ -740,7 +740,7 @@ def test_named_signals(self, tsys):
740740
inputs = ('u[0]', 'u[1]'),
741741
outputs = ('y[0]', 'y[1]'),
742742
states = tsys.mimo_linsys1.states,
743-
name = 'sys1')
743+
name = 'sys1', dt=0)
744744
sys2 = ios.LinearIOSystem(tsys.mimo_linsys2,
745745
inputs = ('u[0]', 'u[1]'),
746746
outputs = ('y[0]', 'y[1]'),
@@ -798,8 +798,8 @@ def test_named_signals(self, tsys):
798798
np.testing.assert_array_almost_equal(ss_feedback.D, lin_feedback.D)
799799

800800
def test_sys_naming_convention(self, tsys):
801-
"""Enforce generic system names 'sys[i]' to be present when systems are created
802-
without explicit names."""
801+
"""Enforce generic system names 'sys[i]' to be present when systems are
802+
created without explicit names."""
803803

804804
ct.InputOutputSystem.idCounter = 0
805805
sys = ct.LinearIOSystem(tsys.mimo_linsys1)
@@ -808,17 +808,17 @@ def test_sys_naming_convention(self, tsys):
808808
assert sys.copy().name == "copy of sys[0]"
809809

810810
namedsys = ios.NonlinearIOSystem(
811-
updfcn = lambda t, x, u, params: x,
812-
outfcn = lambda t, x, u, params: u,
813-
inputs = ('u[0]', 'u[1]'),
814-
outputs = ('y[0]', 'y[1]'),
815-
states = tsys.mimo_linsys1.states,
816-
name = 'namedsys')
811+
updfcn=lambda t, x, u, params: x,
812+
outfcn=lambda t, x, u, params: u,
813+
inputs=('u[0]', 'u[1]'),
814+
outputs=('y[0]', 'y[1]'),
815+
states=tsys.mimo_linsys1.states,
816+
name='namedsys')
817817
unnamedsys1 = ct.NonlinearIOSystem(
818-
lambda t,x,u,params: x, inputs=2, outputs=2, states=2
818+
lambda t, x, u, params: x, inputs=2, outputs=2, states=2
819819
)
820820
unnamedsys2 = ct.NonlinearIOSystem(
821-
None, lambda t,x,u,params: u, inputs=2, outputs=2
821+
None, lambda t, x, u, params: u, inputs=2, outputs=2
822822
)
823823
assert unnamedsys2.name == "sys[2]"
824824

@@ -874,14 +874,14 @@ def test_signals_naming_convention(self, tsys):
874874
assert len(sys.output_index) == sys.noutputs
875875

876876
namedsys = ios.NonlinearIOSystem(
877-
updfcn = lambda t, x, u, params: x,
878-
outfcn = lambda t, x, u, params: u,
879-
inputs = ('u0'),
880-
outputs = ('y0'),
881-
states = ('x0'),
882-
name = 'namedsys')
877+
updfcn=lambda t, x, u, params: x,
878+
outfcn=lambda t, x, u, params: u,
879+
inputs=('u0'),
880+
outputs=('y0'),
881+
states=('x0'),
882+
name='namedsys')
883883
unnamedsys = ct.NonlinearIOSystem(
884-
lambda t,x,u,params: x, inputs=1, outputs=1, states=1
884+
lambda t, x, u, params: x, inputs=1, outputs=1, states=1
885885
)
886886
assert 'u0' in namedsys.input_index
887887
assert 'y0' in namedsys.output_index
@@ -1011,15 +1011,11 @@ def test_lineariosys_statespace(self, tsys):
10111011
np.testing.assert_array_equal(io_feedback.C, ss_feedback.C)
10121012
np.testing.assert_array_equal(io_feedback.D, ss_feedback.D)
10131013

1014-
<<<<<<< HEAD
1015-
def test_duplicates(self):
1016-
=======
1017-
10181014
def test_duplicates(self, tsys):
1019-
>>>>>>> cdbb916 (move test data to fixtures to avoid deprecation warnings during collection)
1020-
nlios = ios.NonlinearIOSystem(lambda t,x,u,params: x, \
1021-
lambda t, x, u, params: u*u, \
1022-
inputs=1, outputs=1, states=1, name="sys")
1015+
nlios = ios.NonlinearIOSystem(lambda t, x, u, params: x,
1016+
lambda t, x, u, params: u * u,
1017+
inputs=1, outputs=1, states=1,
1018+
name="sys", dt=0)
10231019

10241020
# Duplicate objects
10251021
with pytest.warns(UserWarning, match="Duplicate object"):
@@ -1028,7 +1024,7 @@ def test_duplicates(self, tsys):
10281024
# Nonduplicate objects
10291025
nlios1 = nlios.copy()
10301026
nlios2 = nlios.copy()
1031-
with pytest.warns(UserWarning, match="copy of sys") as record:
1027+
with pytest.warns(UserWarning, match="Duplicate name"):
10321028
ios_series = nlios1 * nlios2
10331029
assert "copy of sys_1.x[0]" in ios_series.state_index.keys()
10341030
assert "copy of sys.x[0]" in ios_series.state_index.keys()
@@ -1037,10 +1033,10 @@ def test_duplicates(self, tsys):
10371033
iosys_siso = ct.LinearIOSystem(tsys.siso_linsys)
10381034
nlios1 = ios.NonlinearIOSystem(None,
10391035
lambda t, x, u, params: u * u,
1040-
inputs=1, outputs=1, name="sys")
1036+
inputs=1, outputs=1, name="sys", dt=0)
10411037
nlios2 = ios.NonlinearIOSystem(None,
10421038
lambda t, x, u, params: u * u,
1043-
inputs=1, outputs=1, name="sys")
1039+
inputs=1, outputs=1, name="sys", dt=0)
10441040

10451041
with pytest.warns(UserWarning, match="Duplicate name"):
10461042
ct.InterconnectedSystem((nlios1, iosys_siso, nlios2),
@@ -1049,10 +1045,10 @@ def test_duplicates(self, tsys):
10491045
# Same system, different names => everything should be OK
10501046
nlios1 = ios.NonlinearIOSystem(None,
10511047
lambda t, x, u, params: u * u,
1052-
inputs=1, outputs=1, name="nlios1")
1048+
inputs=1, outputs=1, name="nlios1", dt=0)
10531049
nlios2 = ios.NonlinearIOSystem(None,
10541050
lambda t, x, u, params: u * u,
1055-
inputs=1, outputs=1, name="nlios2")
1051+
inputs=1, outputs=1, name="nlios2", dt=0)
10561052
with pytest.warns(None) as record:
10571053
ct.InterconnectedSystem((nlios1, iosys_siso, nlios2),
10581054
inputs=0, outputs=0, states=0)

0 commit comments

Comments
 (0)