4
4
# RMM, 30 Mar 2011 (based on TestXferFcn from v0.4a)
5
5
6
6
import unittest
7
+ import pytest
8
+
7
9
import sys as pysys
8
10
import numpy as np
9
11
from control .statesp import StateSpace , _convertToStateSpace , rss
@@ -912,8 +914,8 @@ def test_repr(self):
912
914
np .testing .assert_array_almost_equal (
913
915
H .den [p ][m ], H2 .den [p ][m ])
914
916
self .assertEqual (H .dt , H2 .dt )
915
-
916
- def test_sample_system_prewarping (self ):
917
+
918
+ def test_sample_system_prewarping (self ):
917
919
"""test that prewarping works when converting from cont to discrete time system"""
918
920
A = np .array ([
919
921
[ 0.00000000e+00 , 1.00000000e+00 , 0.00000000e+00 , 0.00000000e+00 ],
@@ -929,10 +931,29 @@ def test_sample_system_prewarping(self):
929
931
plant = ss2tf (plant )
930
932
plant_d_warped = plant .sample (Ts , 'bilinear' , prewarp_frequency = wwarp )
931
933
np .testing .assert_array_almost_equal (
932
- evalfr (plant , wwarp * 1j ),
933
- evalfr (plant_d_warped , np .exp (wwarp * 1j * Ts )),
934
+ evalfr (plant , wwarp * 1j ),
935
+ evalfr (plant_d_warped , np .exp (wwarp * 1j * Ts )),
934
936
decimal = 4 )
935
937
938
+ @pytest .mark .parametrize ("dt" ,
939
+ [None ,
940
+ 0 ,
941
+ pytest .param (1 , marks = pytest .mark .xfail (
942
+ reason = "not implemented" )),
943
+ pytest .param (1 , marks = pytest .mark .xfail (
944
+ reason = "not implemented" ))])
945
+ def test_returnScipySignalLTI (dt ):
946
+ """Test returnScipySignalLTI method"""
947
+ sys = TransferFunction ([[[11 ], [12 ], [13 ]],
948
+ [[21 ], [22 ], [23 ]]],
949
+ [[[1 , - 1 ]] * 3 ] * 2 ,
950
+ dt )
951
+ sslti = sys .returnScipySignalLTI ()
952
+ for i in range (2 ):
953
+ for j in range (3 ):
954
+ np .testing .assert_allclose (sslti [i ][j ].num , sys .num [i ][j ])
955
+ np .testing .assert_allclose (sslti [i ][j ].den , sys .den [i ][j ])
956
+
936
957
937
958
if __name__ == "__main__" :
938
959
unittest .main ()
0 commit comments