@@ -33,7 +33,7 @@ def setUp(self):
3333 self .sys1 = StateSpace (A , B , C , D )
3434 self .sys2 = StateSpace (a , b , c , d )
3535
36- def testPole (self ):
36+ def test_pole (self ):
3737 """Evaluate the poles of a MIMO system."""
3838
3939 p = np .sort (self .sys1 .pole ())
@@ -43,13 +43,13 @@ def testPole(self):
4343
4444 np .testing .assert_array_almost_equal (p , true_p )
4545
46- def testEmptyZero (self ):
47- """Test to make sure zero() works with no zeros in system"""
46+ def test_zero_empty (self ):
47+ """Test to make sure zero() works with no zeros in system. """
4848 sys = _convertToStateSpace (TransferFunction ([1 ], [1 , 2 , 1 ]))
4949 np .testing .assert_array_equal (sys .zero (), np .array ([]))
5050
5151 @unittest .skipIf (not slycot_check (), "slycot not installed" )
52- def testMIMOZero_nonsquare (self ):
52+ def test_zero_mimo_non_square (self ):
5353 """Evaluate the zeros of a MIMO system."""
5454
5555 z = np .sort (self .sys1 .zero ())
@@ -80,7 +80,7 @@ def testMIMOZero_nonsquare(self):
8080
8181 np .testing .assert_array_almost_equal (z , true_z )
8282
83- def testAdd (self ):
83+ def test_add_ss (self ):
8484 """Add two MIMO systems."""
8585
8686 A = [[- 3. , 4. , 2. , 0. , 0. ], [- 1. , - 3. , 0. , 0. , 0. ],
@@ -96,7 +96,7 @@ def testAdd(self):
9696 np .testing .assert_array_almost_equal (sys .C , C )
9797 np .testing .assert_array_almost_equal (sys .D , D )
9898
99- def testSub (self ):
99+ def test_subtract_ss (self ):
100100 """Subtract two MIMO systems."""
101101
102102 A = [[- 3. , 4. , 2. , 0. , 0. ], [- 1. , - 3. , 0. , 0. , 0. ],
@@ -112,7 +112,7 @@ def testSub(self):
112112 np .testing .assert_array_almost_equal (sys .C , C )
113113 np .testing .assert_array_almost_equal (sys .D , D )
114114
115- def testMul (self ):
115+ def test_multiply_ss (self ):
116116 """Multiply two MIMO systems."""
117117
118118 A = [[4. , 1. , 0. , 0. , 0. ], [2. , - 3. , 0. , 0. , 0. ], [2. , 0. , - 3. , 4. , 2. ],
@@ -128,7 +128,7 @@ def testMul(self):
128128 np .testing .assert_array_almost_equal (sys .C , C )
129129 np .testing .assert_array_almost_equal (sys .D , D )
130130
131- def testEvalFr (self ):
131+ def test_evalfr (self ):
132132 """Evaluate the frequency response at one frequency."""
133133
134134 A = [[- 2 , 0.5 ], [0.5 , - 0.3 ]]
@@ -159,7 +159,7 @@ def testEvalFr(self):
159159 assert issubclass (w [- 1 ].category , PendingDeprecationWarning )
160160
161161 @unittest .skipIf (not slycot_check (), "slycot not installed" )
162- def testFreqResp (self ):
162+ def test_freq_resp (self ):
163163 """Evaluate the frequency response at multiple frequencies."""
164164
165165 A = [[- 2 , 0.5 ], [0.5 , - 0.3 ]]
@@ -168,25 +168,25 @@ def testFreqResp(self):
168168 D = [[0. , - 0.8 ], [- 0.3 , 0. ]]
169169 sys = StateSpace (A , B , C , D )
170170
171- truemag = [[[0.0852992637230322 , 0.00103596611395218 ],
171+ true_mag = [[[0.0852992637230322 , 0.00103596611395218 ],
172172 [0.935374692849736 , 0.799380720864549 ]],
173173 [[0.55656854563842 , 0.301542699860857 ],
174174 [0.609178071542849 , 0.0382108097985257 ]]]
175- truephase = [[[- 0.566195599644593 , - 1.68063565332582 ],
175+ true_phase = [[[- 0.566195599644593 , - 1.68063565332582 ],
176176 [3.0465958317514 , 3.14141384339534 ]],
177177 [[2.90457947657161 , 3.10601268291914 ],
178178 [- 0.438157380501337 , - 1.40720969147217 ]]]
179- trueomega = [0.1 , 10. ]
179+ true_omega = [0.1 , 10. ]
180180
181- mag , phase , omega = sys .freqresp (trueomega )
181+ mag , phase , omega = sys .freqresp (true_omega )
182182
183- np .testing .assert_almost_equal (mag , truemag )
184- np .testing .assert_almost_equal (phase , truephase )
185- np .testing .assert_equal (omega , trueomega )
183+ np .testing .assert_almost_equal (mag , true_mag )
184+ np .testing .assert_almost_equal (phase , true_phase )
185+ np .testing .assert_equal (omega , true_omega )
186186
187187 @unittest .skipIf (not slycot_check (), "slycot not installed" )
188- def testMinreal (self ):
189- """Test a minreal model reduction"""
188+ def test_minreal (self ):
189+ """Test a minreal model reduction. """
190190 # A = [-2, 0.5, 0; 0.5, -0.3, 0; 0, 0, -0.1]
191191 A = [[- 2 , 0.5 , 0 ], [0.5 , - 0.3 , 0 ], [0 , 0 , - 0.1 ]]
192192 # B = [0.3, -1.3; 0.1, 0; 1, 0]
@@ -205,8 +205,8 @@ def testMinreal(self):
205205 np .testing .assert_array_almost_equal (
206206 eigvals (sysr .A ), [- 2.136154 , - 0.1638459 ])
207207
208- def testAppendSS (self ):
209- """Test appending two state-space systems"""
208+ def test_append_ss (self ):
209+ """Test appending two state-space systems. """
210210 A1 = [[- 2 , 0.5 , 0 ], [0.5 , - 0.3 , 0 ], [0 , 0 , - 0.1 ]]
211211 B1 = [[0.3 , - 1.3 ], [0.1 , 0. ], [1.0 , 0.0 ]]
212212 C1 = [[0. , 0.1 , 0.0 ], [- 0.3 , - 0.2 , 0.0 ]]
@@ -229,7 +229,7 @@ def testAppendSS(self):
229229 np .testing .assert_array_almost_equal (sys3 .C , sys3c .C )
230230 np .testing .assert_array_almost_equal (sys3 .D , sys3c .D )
231231
232- def testAppendTF (self ):
232+ def test_append_tf (self ):
233233 """Test appending a state-space system with a tf"""
234234 A1 = [[- 2 , 0.5 , 0 ], [0.5 , - 0.3 , 0 ], [0 , 0 , - 0.1 ]]
235235 B1 = [[0.3 , - 1.3 ], [0.1 , 0. ], [1.0 , 0.0 ]]
@@ -251,7 +251,7 @@ def testAppendTF(self):
251251 np .testing .assert_array_almost_equal (sys3c .A [:3 , 3 :], np .zeros ((3 , 2 )))
252252 np .testing .assert_array_almost_equal (sys3c .A [3 :, :3 ], np .zeros ((2 , 3 )))
253253
254- def testArrayAccessSS (self ):
254+ def test_array_access_ss (self ):
255255
256256 sys1 = StateSpace ([[1. , 2. ], [3. , 4. ]],
257257 [[5. , 6. ], [6. , 8. ]],
@@ -270,8 +270,8 @@ def testArrayAccessSS(self):
270270
271271 assert sys1 .dt == sys1_11 .dt
272272
273- def test_dcgain_cont (self ):
274- """Test DC gain for continuous-time state-space systems"""
273+ def test_dc_gain_cont (self ):
274+ """Test DC gain for continuous-time state-space systems. """
275275 sys = StateSpace (- 2. , 6. , 5. , 0 )
276276 np .testing .assert_equal (sys .dcgain (), 15. )
277277
@@ -282,8 +282,8 @@ def test_dcgain_cont(self):
282282 sys3 = StateSpace (0. , 1. , 1. , 0. )
283283 np .testing .assert_equal (sys3 .dcgain (), np .nan )
284284
285- def test_dcgain_discr (self ):
286- """Test DC gain for discrete-time state-space systems"""
285+ def test_dc_gain_discr (self ):
286+ """Test DC gain for discrete-time state-space systems. """
287287 # static gain
288288 sys = StateSpace ([], [], [], 2 , True )
289289 np .testing .assert_equal (sys .dcgain (), 2 )
@@ -300,15 +300,16 @@ def test_dcgain_discr(self):
300300 sys = StateSpace (1 , 1 , 1 , 0 , True )
301301 np .testing .assert_equal (sys .dcgain (), np .nan )
302302
303- def test_dcgain_integrator (self ):
304- """DC gain when eigenvalue at DC returns appropriately sized array of nan"""
303+ def test_dc_gain_integrator (self ):
304+ """DC gain when eigenvalue at DC returns appropriately sized array of nan. """
305305 # the SISO case is also tested in test_dc_gain_{cont,discr}
306306 import itertools
307307 # iterate over input and output sizes, and continuous (dt=None) and discrete (dt=True) time
308308 for inputs , outputs , dt in itertools .product (range (1 , 6 ), range (1 , 6 ), [None , True ]):
309309 states = max (inputs , outputs )
310310
311- # a matrix that is singular at DC, and has no "useless" states as in _remove_useless_states
311+ # a matrix that is singular at DC, and has no "useless" states as in
312+ # _remove_useless_states
312313 a = np .triu (np .tile (2 , (states , states )))
313314 # eigenvalues all +2, except for ...
314315 a [0 , 0 ] = 0 if dt is None else 1
@@ -319,7 +320,7 @@ def test_dcgain_integrator(self):
319320 dc = np .squeeze (np .tile (np .nan , (outputs , inputs )))
320321 np .testing .assert_array_equal (dc , sys .dcgain ())
321322
322- def test_scalarStaticGain (self ):
323+ def test_scalar_static_gain (self ):
323324 """Regression: can we create a scalar static gain?"""
324325 g1 = StateSpace ([], [], [], [2 ])
325326 g2 = StateSpace ([], [], [], [3 ])
@@ -335,7 +336,7 @@ def test_scalarStaticGain(self):
335336 g6 = g1 .append (g2 )
336337 np .testing .assert_array_equal (np .diag ([2 , 3 ]), g6 .D )
337338
338- def test_matrixStaticGain (self ):
339+ def test_matrix_static_gain (self ):
339340 """Regression: can we create matrix static gains?"""
340341 d1 = np .matrix ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
341342 d2 = np .matrix ([[7 , 8 ], [9 , 10 ], [11 , 12 ]])
@@ -358,7 +359,7 @@ def test_matrixStaticGain(self):
358359 np .testing .assert_array_equal (block_diag (d1 , d2 ), h4 .D )
359360
360361 def test_remove_useless_states (self ):
361- """Regression: _remove_useless_states gives correct ABC sizes"""
362+ """Regression: _remove_useless_states gives correct ABC sizes. """
362363 g1 = StateSpace (np .zeros ((3 , 3 )),
363364 np .zeros ((3 , 4 )),
364365 np .zeros ((5 , 3 )),
@@ -369,8 +370,8 @@ def test_remove_useless_states(self):
369370 self .assertEqual ((5 , 4 ), g1 .D .shape )
370371 self .assertEqual (0 , g1 .states )
371372
372- def test_BadEmptyMatrices (self ):
373- """Mismatched ABCD matrices when some are empty"""
373+ def test_bad_empty_matrices (self ):
374+ """Mismatched ABCD matrices when some are empty. """
374375 self .assertRaises (ValueError , StateSpace , [1 ], [], [], [1 ])
375376 self .assertRaises (ValueError , StateSpace , [1 ], [1 ], [], [1 ])
376377 self .assertRaises (ValueError , StateSpace , [1 ], [], [1 ], [1 ])
@@ -379,23 +380,23 @@ def test_BadEmptyMatrices(self):
379380 self .assertRaises (ValueError , StateSpace , [], [], [1 ], [1 ])
380381 self .assertRaises (ValueError , StateSpace , [1 ], [1 ], [1 ], [])
381382
382- def test_minrealStaticGain (self ):
383- """Regression: minreal on static gain was failing"""
383+ def test_minreal_static_gain (self ):
384+ """Regression: minreal on static gain was failing. """
384385 g1 = StateSpace ([], [], [], [1 ])
385386 g2 = g1 .minreal ()
386387 np .testing .assert_array_equal (g1 .A , g2 .A )
387388 np .testing .assert_array_equal (g1 .B , g2 .B )
388389 np .testing .assert_array_equal (g1 .C , g2 .C )
389390 np .testing .assert_array_equal (g1 .D , g2 .D )
390391
391- def test_Empty (self ):
392+ def test_empty (self ):
392393 """Regression: can we create an empty StateSpace object?"""
393394 g1 = StateSpace ([], [], [], [])
394395 self .assertEqual (0 , g1 .states )
395396 self .assertEqual (0 , g1 .inputs )
396397 self .assertEqual (0 , g1 .outputs )
397398
398- def test_MatrixToStateSpace (self ):
399+ def test_matrix_to_state_space (self ):
399400 """_convertToStateSpace(matrix) gives ss([],[],[],D)"""
400401 D = np .matrix ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
401402 g = _convertToStateSpace (D )
@@ -421,9 +422,8 @@ def setUp(self):
421422 # Maximum number of inputs and outputs to test + 1
422423 self .maxIO = 5
423424
424- def testShape (self ):
425- """Test that rss outputs have the right state, input, and output
426- size."""
425+ def test_shape (self ):
426+ """Test that rss outputs have the right state, input, and output size."""
427427
428428 for states in range (1 , self .maxStates ):
429429 for inputs in range (1 , self .maxIO ):
@@ -433,7 +433,7 @@ def testShape(self):
433433 self .assertEqual (sys .inputs , inputs )
434434 self .assertEqual (sys .outputs , outputs )
435435
436- def testPole (self ):
436+ def test_pole (self ):
437437 """Test that the poles of rss outputs have a negative real part."""
438438
439439 for states in range (1 , self .maxStates ):
@@ -451,14 +451,13 @@ class TestDrss(unittest.TestCase):
451451 def setUp (self ):
452452 # Number of times to run each of the randomized tests.
453453 self .numTests = 100
454- # Maxmimum number of states to test + 1
454+ # Maximum number of states to test + 1
455455 self .maxStates = 10
456456 # Maximum number of inputs and outputs to test + 1
457457 self .maxIO = 5
458458
459- def testShape (self ):
460- """Test that drss outputs have the right state, input, and output
461- size."""
459+ def test_shape (self ):
460+ """Test that drss outputs have the right state, input, and output size."""
462461
463462 for states in range (1 , self .maxStates ):
464463 for inputs in range (1 , self .maxIO ):
@@ -468,7 +467,7 @@ def testShape(self):
468467 self .assertEqual (sys .inputs , inputs )
469468 self .assertEqual (sys .outputs , outputs )
470469
471- def testPole (self ):
470+ def test_pole (self ):
472471 """Test that the poles of drss outputs have less than unit magnitude."""
473472
474473 for states in range (1 , self .maxStates ):
@@ -479,8 +478,8 @@ def testPole(self):
479478 for z in p :
480479 self .assertTrue (abs (z ) < 1 )
481480
482- def testPoleStatic (self ):
483- """Regression: pole() of static gain is empty array"""
481+ def test_pole_static (self ):
482+ """Regression: pole() of static gain is empty array. """
484483 np .testing .assert_array_equal (np .array ([]),
485484 StateSpace ([], [], [], [[1 ]]).pole ())
486485
0 commit comments