8000 avoid different realizations with and without slycot · python-control/python-control@3e1b615 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e1b615

Browse files
committed
avoid different realizations with and without slycot
1 parent d346d4e commit 3e1b615

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

control/tests/timeresp_test.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,18 @@ def tsystem(self, request):
126126
[ 0. , -0.1097, -0.1902, -0.2438, -0.2729,
127127
-0.2799, -0.2674, -0.2377, -0.1934, -0.1368])
128128

129+
"""dtf1 converted statically, because Slycot and Scipy produce
130+
different realizations, wich means different initial condtions,"""
129131
siso_dss1 = copy(siso_dtf1)
130-
siso_dss1.sys = tf2ss(siso_dtf1.sys)
131-
siso_dss1.yinitial = np.array([-1., -0.5, 0.75, -0.625, 0.4375])
132+
siso_dss1.sys = StateSpace([[-1., -0.25],
133+
[ 1., 0.]],
134+
[[1.],
135+
[0.]],
136+
[[0., 1.]],
137+
[[0.]],
138+
True)
139+
siso_dss1.X0 = [0.5, 1.]
140+
siso_dss1.yinitial = np.array([1., 0.5, -0.75, 0.625, -0.4375])
132141

133142
siso_dss2 = copy(siso_dtf2)
134143
siso_dss2.sys = tf2ss(siso_dtf2.sys)
@@ -648,12 +657,10 @@ def test_forced_response_legacy(self):
648657
@pytest.mark.parametrize(
649658
"tsystem, fr_kwargs, refattr",
650659
[pytest.param("siso_ss1",
651-
{'X0': [0.5, 1], 'T': np.linspace(0, 1, 10)},
652-
'yinitial',
660+
{'T': np.linspace(0, 1, 10)}, 'yinitial',
653661
id="ctime no U"),
654662
pytest.param("siso_dss1",
655-
{'T': np.arange(0, 5, 1,),
656-
'X0': [0.5, 1]}, 'yinitial',
663+
{'T': np.arange(0, 5, 1,)}, 'yinitial',
657664
id="dt=True, no U"),
658665
pytest.param("siso_dtf1",
659666
{'U': np.ones(5,)}, 'ystep',
@@ -671,6 +678,8 @@ def test_forced_response_legacy(self):
671678
indirect=["tsystem"])
672679
def test_forced_response_T_U(self, tsystem, fr_kwargs, refattr):
673680
"""Test documented forced_response behavior for parameters T and U."""
681+
if refattr == 'yinitial':
682+
fr_kwargs['X0'] = tsystem.X0
674683
t, y = forced_response(tsystem.sys, **fr_kwargs)
675684
np.testing.assert_allclose(t, tsystem.t)
676685
np.testing.assert_allclose(y, getattr(tsystem, refattr), rtol=1e-3)

0 commit comments

Comments
 (0)
0