@@ -130,9 +130,10 @@ def test_iosys_print(self, tsys, capsys):
130130 print (ios_linearized )
131131
132132 @noscipy0
133- def test_nonlinear_iosys (self , tsys ):
133+ @pytest .mark .parametrize ("ss" , [ios .NonlinearIOSystem , ct .ss ])
134+ def test_nonlinear_iosys (self , tsys , ss ):
134135 # Create a simple nonlinear I/O system
135- nlsys = ios . NonlinearIOSystem (predprey )
136+ nlsys = ss (predprey )
136137 T = tsys .T
137138
138139 # Start by simulating from an equilibrium point
@@ -159,7 +160,7 @@ def test_nonlinear_iosys(self, tsys):
159160 np .reshape (linsys .C @ np .reshape (x , (- 1 , 1 ))
160161 + linsys .D @ np .reshape (u , (- 1 , 1 )),
161162 (- 1 ,))
162- nlsys = ios . NonlinearIOSystem (nlupd , nlout , inputs = 1 , outputs = 1 )
163+ nlsys = ss (nlupd , nlout , inputs = 1 , outputs = 1 )
163164
164165 # Make sure that simulations also line up
165166 T , U , X0 = tsys .T , tsys .U , tsys .X0
@@ -1775,3 +1776,21 @@ def test_nonuniform_timepts():
17751776 t_even , y_even = ct .input_output_response (
17761777 sys , noufpts , nonunif , t_eval = unifpts )
17771778 np .testing .assert_almost_equal (y_unif , y_even , decimal = 6 )
1779+
1780+
1781+ def test_ss_nonlinear ():
1782+ """Test ss() for creating nonlinear systems"""
1783+ secord = ct .ss (secord_update , secord_output , inputs = 'u' , outputs = 'y' ,
1784+ states = ['x1' , 'x2' ], name = 'secord' )
1785+ assert secord .name == 'secord'
1786+ assert secord .input_labels == ['u' ]
1787+ assert secord .output_labels == ['y' ]
1788+ assert secord .state_labels == ['x1' , 'x2' ]
1789+
1790+ # Make sure that optional keywords are allowed
1791+ secord = ct .ss (secord_update , secord_output , dt = True )
1792+ assert ct .isdtime (secord )
1793+
1794+ # Make sure that state space keywords are flagged
1795+ with pytest .raises (TypeError , match = "unrecognized keyword" ):
1796+ ct .ss (secord_update , remove_useless_states = True )
0 commit comments