@@ -347,7 +347,7 @@ def test_impulse_response_mimo(self, mimo_ss2):
347347 yref_notrim = np .zeros ((2 , len (t )))
348348 yref_notrim [:1 , :] = yref
349349 _t , yy = impulse_response (sys , T = t , input = 0 )
350- np .testing .assert_array_almost_equal (yy , yref_notrim , decimal = 4 )
350+ np .testing .assert_array_almost_equal (yy [:, 0 ,:] , yref_notrim , decimal = 4 )
351351
352352 @pytest .mark .skipif (StrictVersion (sp .__version__ ) < "1.3" ,
353353 reason = "requires SciPy 1.3 or greater" )
@@ -770,7 +770,7 @@ def test_squeeze(self, fcn, nstate, nout, ninp, squeeze, shape1, shape2):
770770 # Check the states as well
771771 _ , yvec , xvec = ct .impulse_response (
772772 sys , tvec , squeeze = squeeze , return_x = True )
773- if sys .issiso () and squeeze is not False :
773+ if sys .issiso ():
774774 assert xvec .shape == (sys .states , 8 )
775775 else :
776776 assert xvec .shape == (sys .states , sys .inputs , 8 )
@@ -783,7 +783,7 @@ def test_squeeze(self, fcn, nstate, nout, ninp, squeeze, shape1, shape2):
783783 # Check the states as well
784784 _ , yvec , xvec = ct .step_response (
785785 sys , tvec , squeeze = squeeze , return_x = True )
786- if sys .issiso () and squeeze is not False :
786+ if sys .issiso ():
787787 assert xvec .shape == (sys .states , 8 )
788788 else :
789789 assert xvec .shape == (sys .states , sys .inputs , 8 )
@@ -894,3 +894,37 @@ def test_squeeze_0_8_4(self, nstate, nout, ninp, squeeze, shape):
894894
895895 _ , yvec = ct .initial_response (sys , tvec , 1 , squeeze = squeeze )
896896 assert yvec .shape == shape
897+
898+ @pytest .mark .parametrize (
899+ "nstate, nout, ninp, squeeze, ysh_in, ysh_no, xsh_in" , [
900+ [4 , 1 , 1 , None , (8 ,), (8 ,), (8 , 4 )],
901+ [4 , 1 , 1 , True , (8 ,), (8 ,), (8 , 4 )],
902+ [4 , 1 , 1 , False , (8 , 1 , 1 ), (8 , 1 ), (8 , 4 )],
903+ [4 , 2 , 1 , None , (8 , 2 , 1 ), (8 , 2 ), (8 , 4 , 1 )],
904+ [4 , 2 , 1 , True , (8 , 2 ), (8 , 2 ), (8 , 4 , 1 )],
905+ [4 , 2 , 1 , False , (8 , 2 , 1 ), (8 , 2 ), (8 , 4 , 1 )],
906+ [4 , 1 , 2 , None , (8 , 1 , 2 ), (8 , 1 ), (8 , 4 , 2 )],
907+ [4 , 1 , 2 , True , (8 , 2 ), (8 ,), (8 , 4 , 2 )],
908+ [4 , 1 , 2 , False , (8 , 1 , 2 ), (8 , 1 ), (8 , 4 , 2 )],
909+ [4 , 2 , 2 , None , (8 , 2 , 2 ), (8 , 2 ), (8 , 4 , 2 )],
910+ [4 , 2 , 2 , True , (8 , 2 , 2 ), (8 , 2 ), (8 , 4 , 2 )],
911+ [4 , 2 , 2 , False , (8 , 2 , 2 ), (8 , 2 ), (8 , 4 , 2 )],
912+ ])
913+ def test_response_transpose (
914+ self , nstate , nout , ninp , squeeze , ysh_in , ysh_no , xsh_in ):
915+ sys = ct .rss (nstate , nout , ninp )
916+ T = np .linspace (0 , 1 , 8 )
917+
918+ # Step response - input indexed
919+ t , y , x = ct .step_response (
920+ sys , T , transpose = True , return_x = True , squeeze = squeeze )
921+ assert t .shape == (T .size , )
922+ assert y .shape == ysh_in
923+ assert x .shape == xsh_in
924+
925+ # Initial response - no input indexing
926+ t , y , x = ct .initial_response (
927+ sys , T , 1 , transpose = True , return_x = True , squeeze = squeeze )
928+ assert t .shape == (T .size , )
929+ assert y .shape == ysh_no
930+ assert x .shape == (T .size , sys .states )
0 commit comments