@@ -1763,27 +1763,40 @@ def test_input_output_broadcasting():
1763
1763
resp_bad = ct .input_output_response (
1764
1764
sys , T , (U [0 , :], U [:2 , :- 1 ]), [X0 , P0 ])
1765
1765
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 ):
1768
1773
"""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 ))
1770
1780
1771
1781
# Start with a uniform set of times
1772
1782
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 )
1775
1787
1776
1788
# Create a non-uniform set of inputs
1777
1789
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 )
1780
1793
1781
1794
# 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 )
1783
1796
1784
1797
# Resimulate using a new set of evaluation points
1785
1798
t_even , y_even = ct .input_output_response (
1786
- sys , noufpts , nonunif , t_eval = unifpts )
1799
+ sys , noufpts , nonunif , t_eval = unifpts , squeeze = False )
1787
1800
np .testing .assert_almost_equal (y_unif , y_even , decimal = 6 )
1788
1801
1789
1802
0 commit comments