@@ -1763,27 +1763,40 @@ def test_input_output_broadcasting():
17631763 resp_bad = ct .input_output_response (
17641764 sys , T , (U [0 , :], U [:2 , :- 1 ]), [X0 , P0 ])
17651765
1766-
1767- def test_nonuniform_timepts ():
1766+ @pytest .mark .parametrize ("nstates, ninputs, noutputs" , [
1767+ [2 , 1 , 1 ],
1768+ [4 , 2 , 3 ],
1769+ [0 , 1 , 1 ], # static function
1770+ [0 , 3 , 2 ], # static function
1771+ ])
1772+ def test_nonuniform_timepts (nstates , noutputs , ninputs ):
17681773 """Test non-uniform time points for simulations"""
1769- sys = ct .LinearIOSystem (ct .rss (2 , 1 , 1 ))
1774+ if nstates :
1775+ sys = ct .rss (nstates , noutputs , ninputs )
1776+ else :
1777+ sys = ct .ss (
1778+ [], np .zeros ((0 , ninputs )), np .zeros ((noutputs , 0 )),
1779+ np .random .rand (noutputs , ninputs ))
17701780
17711781 # Start with a uniform set of times
17721782 unifpts = [0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
1773- uniform = [1 , 2 , 3 , 2 , 1 , - 1 , - 3 , - 5 , - 7 , - 3 , 1 ]
1774- t_unif , y_unif = ct .input_output_response (sys , unifpts , uniform )
1783+ uniform = np .outer (
1784+ np .ones (ninputs ), [1 , 2 , 3 , 2 , 1 , - 1 , - 3 , - 5 , - 7 , - 3 , 1 ])
1785+ t_unif , y_unif = ct .input_output_response (
1786+ sys , unifpts , uniform , squeeze = False )
17751787
17761788 # Create a non-uniform set of inputs
17771789 noufpts = [0 , 2 , 4 , 8 , 10 ]
1778- nonunif = [1 , 3 , 1 , - 7 , 1 ]
1779- t_nouf , y_nouf = ct .input_output_response (sys , noufpts , nonunif )
1790+ nonunif = np .outer (np .ones (ninputs ), [1 , 3 , 1 , - 7 , 1 ])
1791+ t_nouf , y_nouf = ct .input_output_response (
1792+ sys , noufpts , nonunif , squeeze = False )
17801793
17811794 # Make sure the outputs agree at common times
1782- np .testing .assert_almost_equal (y_unif [noufpts ], y_nouf , decimal = 6 )
1795+ np .testing .assert_almost_equal (y_unif [:, noufpts ], y_nouf , decimal = 6 )
17831796
17841797 # Resimulate using a new set of evaluation points
17851798 t_even , y_even = ct .input_output_response (
1786- sys , noufpts , nonunif , t_eval = unifpts )
1799+ sys , noufpts , nonunif , t_eval = unifpts , squeeze = False )
17871800 np .testing .assert_almost_equal (y_unif , y_even , decimal = 6 )
17881801
17891802
0 commit comments