Skip to content

Commit

Permalink
avoid different realizations with and without slycot
Browse files Browse the repository at this point in the history
  • Loading branch information
bnavigator committed Apr 1, 2021
1 parent d346d4e commit 3e1b615
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions control/tests/timeresp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,18 @@ def tsystem(self, request):
[ 0. , -0.1097, -0.1902, -0.2438, -0.2729,
-0.2799, -0.2674, -0.2377, -0.1934, -0.1368])

"""dtf1 converted statically, because Slycot and Scipy produce
different realizations, wich means different initial condtions,"""
siso_dss1 = copy(siso_dtf1)
siso_dss1.sys = tf2ss(siso_dtf1.sys)
siso_dss1.yinitial = np.array([-1., -0.5, 0.75, -0.625, 0.4375])
siso_dss1.sys = StateSpace([[-1., -0.25],
[ 1., 0.]],
[[1.],
[0.]],
[[0., 1.]],
[[0.]],
True)
siso_dss1.X0 = [0.5, 1.]
siso_dss1.yinitial = np.array([1., 0.5, -0.75, 0.625, -0.4375])

siso_dss2 = copy(siso_dtf2)
siso_dss2.sys = tf2ss(siso_dtf2.sys)
Expand Down Expand Up @@ -648,12 +657,10 @@ def test_forced_response_legacy(self):
@pytest.mark.parametrize(
"tsystem, fr_kwargs, refattr",
[pytest.param("siso_ss1",
{'X0': [0.5, 1], 'T': np.linspace(0, 1, 10)},
'yinitial',
{'T': np.linspace(0, 1, 10)}, 'yinitial',
id="ctime no U"),
pytest.param("siso_dss1",
{'T': np.arange(0, 5, 1,),
'X0': [0.5, 1]}, 'yinitial',
{'T': np.arange(0, 5, 1,)}, 'yinitial',
id="dt=True, no U"),
pytest.param("siso_dtf1",
{'U': np.ones(5,)}, 'ystep',
Expand All @@ -671,6 +678,8 @@ def test_forced_response_legacy(self):
indirect=["tsystem"])
def test_forced_response_T_U(self, tsystem, fr_kwargs, refattr):
"""Test documented forced_response behavior for parameters T and U."""
if refattr == 'yinitial':
fr_kwargs['X0'] = tsystem.X0
t, y = forced_response(tsystem.sys, **fr_kwargs)
np.testing.assert_allclose(t, tsystem.t)
np.testing.assert_allclose(y, getattr(tsystem, refattr), rtol=1e-3)
Expand Down

0 comments on commit 3e1b615

Please sign in to comment.