@@ -33,7 +33,7 @@ def setUp(self):
33
33
self .sys1 = StateSpace (A , B , C , D )
34
34
self .sys2 = StateSpace (a , b , c , d )
35
35
36
- def testPole (self ):
36
+ def test_pole (self ):
37
37
"""Evaluate the poles of a MIMO system."""
38
38
39
39
p = np .sort (self .sys1 .pole ())
@@ -43,13 +43,13 @@ def testPole(self):
43
43
44
44
np .testing .assert_array_almost_equal (p , true_p )
45
45
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. """
48
48
sys = _convertToStateSpace (TransferFunction ([1 ], [1 , 2 , 1 ]))
49
49
np .testing .assert_array_equal (sys .zero (), np .array ([]))
50
50
51
51
@unittest .skipIf (not slycot_check (), "slycot not installed" )
52
- def testMIMOZero_nonsquare (self ):
52
+ def test_zero_mimo_non_square (self ):
53
53
"""Evaluate the zeros of a MIMO system."""
54
54
55
55
z = np .sort (self .sys1 .zero ())
@@ -80,7 +80,7 @@ def testMIMOZero_nonsquare(self):
80
80
81
81
np .testing .assert_array_almost_equal (z , true_z )
82
82
83
- def testAdd (self ):
83
+ def test_add_ss (self ):
84
84
"""Add two MIMO systems."""
85
85
86
86
A = [[- 3. , 4. , 2. , 0. , 0. ], [- 1. , - 3. , 0. , 0. , 0. ],
@@ -96,7 +96,7 @@ def testAdd(self):
96
96
np .testing .assert_array_almost_equal (sys .C , C )
97
97
np .testing .assert_array_almost_equal (sys .D , D )
98
98
99
- def testSub (self ):
99
+ def test_subtract_ss (self ):
100
100
"""Subtract two MIMO systems."""
101
101
102
102
A = [[- 3. , 4. , 2. , 0. , 0. ], [- 1. , - 3. , 0. , 0. , 0. ],
@@ -112,7 +112,7 @@ def testSub(self):
112
112
np .testing .assert_array_almost_equal (sys .C , C )
113
113
np .testing .assert_array_almost_equal (sys .D , D )
114
114
115
- def testMul (self ):
115
+ def test_multiply_ss (self ):
116
116
"""Multiply two MIMO systems."""
117
117
118
118
A = [[4. , 1. , 0. , 0. , 0. ], [2. , - 3. , 0. , 0. , 0. ], [2. , 0. , - 3. , 4. , 2. ],
@@ -128,7 +128,7 @@ def testMul(self):
128
128
np .testing .assert_array_almost_equal (sys .C , C )
129
129
np .testing .assert_array_almost_equal (sys .D , D )
130
130
131
- def testEvalFr (self ):
131
+ def test_evalfr (self ):
132
132
"""Evaluate the frequency response at one frequency."""
133
133
134
134
A = [[- 2 , 0.5 ], [0.5 , - 0.3 ]]
@@ -159,7 +159,7 @@ def testEvalFr(self):
159
159
assert issubclass (w [- 1 ].category , PendingDeprecationWarning )
160
160
161
161
@unittest .skipIf (not slycot_check (), "slycot not installed" )
162
- def testFreqResp (self ):
162
+ def test_freq_resp (self ):
163
163
"""Evaluate the frequency response at multiple frequencies."""
164
164
165
165
A = [[- 2 , 0.5 ], [0.5 , - 0.3 ]]
@@ -168,25 +168,25 @@ def testFreqResp(self):
168
168
D = [[0. , - 0.8 ], [- 0.3 , 0. ]]
169
169
sys = StateSpace (A , B , C , D )
170
170
171
- truemag = [[[0.0852992637230322 , 0.00103596611395218 ],
171
+ true_mag = [[[0.0852992637230322 , 0.00103596611395218 ],
172
172
[0.935374692849736 , 0.799380720864549 ]],
173
173
[[0.55656854563842 , 0.301542699860857 ],
174
174
[0.609178071542849 , 0.0382108097985257 ]]]
175
- truephase = [[[- 0.566195599644593 , - 1.68063565332582 ],
175
+ true_phase = [[[- 0.566195599644593 , - 1.68063565332582 ],
176
176
[3.0465958317514 , 3.14141384339534 ]],
177
177
[[2.90457947657161 , 3.10601268291914 ],
178
178
[- 0.438157380501337 , - 1.40720969147217 ]]]
179
- trueomega = [0.1 , 10. ]
179
+ true_omega = [0.1 , 10. ]
180
180
181
- mag , phase , omega = sys .freqresp (trueomega )
181
+ mag , phase , omega = sys .freqresp (true_omega )
182
182
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 )
186
186
187
187
@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. """
190
190
# A = [-2, 0.5, 0; 0.5, -0.3, 0; 0, 0, -0.1]
191
191
A = [[- 2 , 0.5 , 0 ], [0.5 , - 0.3 , 0 ], [0 , 0 , - 0.1 ]]
192
192
# B = [0.3, -1.3; 0.1, 0; 1, 0]
@@ -205,8 +205,8 @@ def testMinreal(self):
205
205
np .testing .assert_array_almost_equal (
206
206
eigvals (sysr .A ), [- 2.136154 , - 0.1638459 ])
207
207
208
- def testAppendSS (self ):
209
- """Test appending two state-space systems"""
208
+ def test_append_ss (self ):
209
+ """Test appending two state-space systems. """
210
210
A1 = [[- 2 , 0.5 , 0 ], [0.5 , - 0.3 , 0 ], [0 , 0 , - 0.1 ]]
211
211
B1 = [[0.3 , - 1.3 ], [0.1 , 0. ], [1.0 , 0.0 ]]
212
212
C1 = [[0. , 0.1 , 0.0 ], [- 0.3 , - 0.2 , 0.0 ]]
@@ -229,7 +229,7 @@ def testAppendSS(self):
229
229
np .testing .assert_array_almost_equal (sys3 .C , sys3c .C )
230
230
np .testing .assert_array_almost_equal (sys3 .D , sys3c .D )
231
231
232
- def testAppendTF (self ):
232
+ def test_append_tf (self ):
233
233
"""Test appending a state-space system with a tf"""
234
234
A1 = [[- 2 , 0.5 , 0 ], [0.5 , - 0.3 , 0 ], [0 , 0 , - 0.1 ]]
235
235
B1 = [[0.3 , - 1.3 ], [0.1 , 0. ], [1.0 , 0.0 ]]
@@ -251,7 +251,7 @@ def testAppendTF(self):
251
251
np .testing .assert_array_almost_equal (sys3c .A [:3 , 3 :], np .zeros ((3 , 2 )))
252
252
np .testing .assert_array_almost_equal (sys3c .A [3 :, :3 ], np .zeros ((2 , 3 )))
253
253
254
- def testArrayAccessSS (self ):
254
+ def test_array_access_ss (self ):
255
255
256
256
sys1 = StateSpace ([[1. , 2. ], [3. , 4. ]],
257
257
[[5. , 6. ], [6. , 8. ]],
@@ -270,8 +270,8 @@ def testArrayAccessSS(self):
270
270
271
271
assert sys1 .dt == sys1_11 .dt
272
272
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. """
275
275
sys = StateSpace (- 2. , 6. , 5. , 0 )
276
276
np .testing .assert_equal (sys .dcgain (), 15. )
277
277
@@ -282,8 +282,8 @@ def test_dcgain_cont(self):
282
282
sys3 = StateSpace (0. , 1. , 1. , 0. )
283
283
np .testing .assert_equal (sys3 .dcgain (), np .nan )
284
284
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. """
287
287
# static gain
288
288
sys = StateSpace ([], [], [], 2 , True )
289
289
np .testing .assert_equal (sys .dcgain (), 2 )
@@ -300,15 +300,16 @@ def test_dcgain_discr(self):
300
300
sys = StateSpace (1 , 1 , 1 , 0 , True )
301
301
np .testing .assert_equal (sys .dcgain (), np .nan )
302
302
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. """
305
305
# the SISO case is also tested in test_dc_gain_{cont,discr}
306
306
import itertools
307
307
# iterate over input and output sizes, and continuous (dt=None) and discrete (dt=True) time
308
308
for inputs , outputs , dt in itertools .product (range (1 , 6 ), range (1 , 6 ), [None , True ]):
309
309
states = max (inputs , outputs )
310
310
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
312
313
a = np .triu (np .tile (2 , (states , states )))
313
314
# eigenvalues all +2, except for ...
314
315
a [0 , 0 ] = 0 if dt is None else 1
@@ -319,7 +320,7 @@ def test_dcgain_integrator(self):
319
320
dc = np .squeeze (np .tile (np .nan , (outputs , inputs )))
320
321
np .testing .assert_array_equal (dc , sys .dcgain ())
321
322
322
- def test_scalarStaticGain (self ):
323
+ def test_scalar_static_gain (self ):
323
324
"""Regression: can we create a scalar static gain?"""
324
325
g1 = StateSpace ([], [], [], [2 ])
325
326
g2 = StateSpace ([], [], [], [3 ])
@@ -335,7 +336,7 @@ def test_scalarStaticGain(self):
335
336
g6 = g1 .append (g2 )
336
337
np .testing .assert_array_equal (np .diag ([2 , 3 ]), g6 .D )
337
338
338
- def test_matrixStaticGain (self ):
339
+ def test_matrix_static_gain (self ):
339
340
"""Regression: can we create matrix static gains?"""
340
341
d1 = np .matrix ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
341
342
d2 = np .matrix ([[7 , 8 ], [9 , 10 ], [11 , 12 ]])
@@ -358,7 +359,7 @@ def test_matrixStaticGain(self):
358
359
np .testing .assert_array_equal (block_diag (d1 , d2 ), h4 .D )
359
360
360
361
def test_remove_useless_states (self ):
361
- """Regression: _remove_useless_states gives correct ABC sizes"""
362
+ """Regression: _remove_useless_states gives correct ABC sizes. """
362
363
g1 = StateSpace (np .zeros ((3 , 3 )),
363
364
np .zeros ((3 , 4 )),
364
365
np .zeros ((5 , 3 )),
@@ -369,8 +370,8 @@ def test_remove_useless_states(self):
369
370
self .assertEqual ((5 , 4 ), g1 .D .shape )
370
371
self .assertEqual (0 , g1 .states )
371
372
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. """
374
375
self .assertRaises (ValueError , StateSpace , [1 ], [], [], [1 ])
375
376
self .assertRaises (ValueError , StateSpace , [1 ], [1 ], [], [1 ])
376
377
self .assertRaises (ValueError , StateSpace , [1 ], [], [1 ], [1 ])
@@ -379,23 +380,23 @@ def test_BadEmptyMatrices(self):
379
380
self .assertRaises (ValueError , StateSpace , [], [], [1 ], [1 ])
380
381
self .assertRaises (ValueError , StateSpace , [1 ], [1 ], [1 ], [])
381
382
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. """
384
385
g1 = StateSpace ([], [], [], [1 ])
385
386
g2 = g1 .minreal ()
386
387
np .testing .assert_array_equal (g1 .A , g2 .A )
387
388
np .testing .assert_array_equal (g1 .B , g2 .B )
388
389
np .testing .assert_array_equal (g1 .C , g2 .C )
389
390
np .testing .assert_array_equal (g1 .D , g2 .D )
390
391
391
- def test_Empty (self ):
392
+ def test_empty (self ):
392
393
"""Regression: can we create an empty StateSpace object?"""
393
394
g1 = StateSpace ([], [], [], [])
394
395
self .assertEqual (0 , g1 .states )
395
396
self .assertEqual (0 , g1 .inputs )
396
397
self .assertEqual (0 , g1 .outputs )
397
398
398
- def test_MatrixToStateSpace (self ):
399
+ def test_matrix_to_state_space (self ):
399
400
"""_convertToStateSpace(matrix) gives ss([],[],[],D)"""
400
401
D = np .matrix ([[1 , 2 , 3 ], [4 , 5 , 6 ]])
401
402
g = _convertToStateSpace (D )
@@ -421,9 +422,8 @@ def setUp(self):
421
422
# Maximum number of inputs and outputs to test + 1
422
423
self .maxIO = 5
423
424
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."""
427
427
428
428
for states in range (1 , self .maxStates ):
429
429
for inputs in range (1 , self .maxIO ):
@@ -433,7 +433,7 @@ def testShape(self):
433
433
self .assertEqual (sys .inputs , inputs )
434
434
self .assertEqual (sys .outputs , outputs )
435
435
436
- def testPole (self ):
436
+ def test_pole (self ):
437
437
"""Test that the poles of rss outputs have a negative real part."""
438
438
439
439
for states in range (1 , self .maxStates ):
@@ -451,14 +451,13 @@ class TestDrss(unittest.TestCase):
451
451
def setUp (self ):
452
452
# Number of times to run each of the randomized tests.
453
453
self .numTests = 100
454
- # Maxmimum number of states to test + 1
454
+ # Maximum number of states to test + 1
455
455
self .maxStates = 10
456
456
# Maximum number of inputs and outputs to test + 1
457
457
self .maxIO = 5
458
458
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."""
462
461
463
462
for states in range (1 , self .maxStates ):
464
463
for inputs in range (1 , self .maxIO ):
@@ -468,7 +467,7 @@ def testShape(self):
468
467
self .assertEqual (sys .inputs , inputs )
469
468
self .assertEqual (sys .outputs , outputs )
470
469
471
- def testPole (self ):
470
+ def test_pole (self ):
472
471
"""Test that the poles of drss outputs have less than unit magnitude."""
473
472
474
473
for states in range (1 , self .maxStates ):
@@ -479,8 +478,8 @@ def testPole(self):
479
478
for z in p :
480
479
self .assertTrue (abs (z ) < 1 )
481
480
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. """
484
483
np .testing .assert_array_equal (np .array ([]),
485
484
StateSpace ([], [], [], [[1 ]]).pole ())
486
485
0 commit comments