99
1010from control import StateSpace , forced_response , tf , rss , c2d
1111from control .exception import ControlMIMONotImplemented
12- from control .tests .conftest import slycotonly , matarrayin
12+ from control .tests .conftest import slycotonly
1313from control .modelsimp import balred , hsvd , markov , modred
1414
1515
1616class TestModelsimp :
1717 """Test model reduction functions"""
1818
1919 @slycotonly
20- def testHSVD (self , matarrayout , matarrayin ):
21- A = matarrayin ([[1. , - 2. ], [3. , - 4. ]])
22- B = matarrayin ([[5. ], [7. ]])
23- C = matarrayin ([[6. , 8. ]])
24- D = matarrayin ([[9. ]])
20+ def testHSVD (self ):
21+ A = np . array ([[1. , - 2. ], [3. , - 4. ]])
22+ B = np . array ([[5. ], [7. ]])
23+ C = np . array ([[6. , 8. ]])
24+ D = np . array ([[9. ]])
2525 sys = StateSpace (A , B , C , D )
2626 hsv = hsvd (sys )
2727 hsvtrue = np .array ([24.42686 , 0.5731395 ]) # from MATLAB
@@ -32,8 +32,8 @@ def testHSVD(self, matarrayout, matarrayin):
3232 assert isinstance (hsv , np .ndarray )
3333 assert not isinstance (hsv , np .matrix )
3434
35- def testMarkovSignature (self , matarrayout , matarrayin ):
36- U = matarrayin ([[1. , 1. , 1. , 1. , 1. ]])
35+ def testMarkovSignature (self ):
36+ U = np . array ([[1. , 1. , 1. , 1. , 1. ]])
3737 Y = U
3838 m = 3
3939 H = markov (Y , U , m , transpose = False )
@@ -111,17 +111,17 @@ def testMarkovResults(self, k, m, n):
111111 # for k=5, m=n=10: 0.015 %
112112 np .testing .assert_allclose (Mtrue , Mcomp , rtol = 1e-6 , atol = 1e-8 )
113113
114- def testModredMatchDC (self , matarrayin ):
114+ def testModredMatchDC (self ):
115115 #balanced realization computed in matlab for the transfer function:
116116 # num = [1 11 45 32], den = [1 15 60 200 60]
117- A = matarrayin (
117+ A = np . array (
118118 [[- 1.958 , - 1.194 , 1.824 , - 1.464 ],
119119 [- 1.194 , - 0.8344 , 2.563 , - 1.351 ],
120120 [- 1.824 , - 2.563 , - 1.124 , 2.704 ],
121121 [- 1.464 , - 1.351 , - 2.704 , - 11.08 ]])
122- B = matarrayin ([[- 0.9057 ], [- 0.4068 ], [- 0.3263 ], [- 0.3474 ]])
123- C = matarrayin ([[- 0.9057 , - 0.4068 , 0.3263 , - 0.3474 ]])
124- D = matarrayin ([[0. ]])
122+ B = np . array ([[- 0.9057 ], [- 0.4068 ], [- 0.3263 ], [- 0.3474 ]])
123+ C = np . array ([[- 0.9057 , - 0.4068 , 0.3263 , - 0.3474 ]])
124+ D = np . array ([[0. ]])
125125 sys = StateSpace (A , B , C , D )
126126 rsys = modred (sys ,[2 , 3 ],'matchdc' )
127127 Artrue = np .array ([[- 4.431 , - 4.552 ], [- 4.552 , - 5.361 ]])
@@ -133,30 +133,30 @@ def testModredMatchDC(self, matarrayin):
133133 np .testing .assert_array_almost_equal (rsys .C , Crtrue , decimal = 3 )
134134 np .testing .assert_array_almost_equal (rsys .D , Drtrue , decimal = 2 )
135135
136- def testModredUnstable (self , matarrayin ):
136+ def testModredUnstable (self ):
137137 """Check if an error is thrown when an unstable system is given"""
138- A = matarrayin (
138+ A = np . array (
139139 [[4.5418 , 3.3999 , 5.0342 , 4.3808 ],
140140 [0.3890 , 0.3599 , 0.4195 , 0.1760 ],
141141 [- 4.2117 , - 3.2395 , - 4.6760 , - 4.2180 ],
142142 [0.0052 , 0.0429 , 0.0155 , 0.2743 ]])
143- B = matarrayin ([[1.0 , 1.0 ], [2.0 , 2.0 ], [3.0 , 3.0 ], [4.0 , 4.0 ]])
144- C = matarrayin ([[1.0 , 2.0 , 3.0 , 4.0 ], [1.0 , 2.0 , 3.0 , 4.0 ]])
145- D = matarrayin ([[0.0 , 0.0 ], [0.0 , 0.0 ]])
143+ B = np . array ([[1.0 , 1.0 ], [2.0 , 2.0 ], [3.0 , 3.0 ], [4.0 , 4.0 ]])
144+ C = np . array ([[1.0 , 2.0 , 3.0 , 4.0 ], [1.0 , 2.0 , 3.0 , 4.0 ]])
145+ D = np . array ([[0.0 , 0.0 ], [0.0 , 0.0 ]])
146146 sys = StateSpace (A , B , C , D )
147147 np .testing .assert_raises (ValueError , modred , sys , [2 , 3 ])
148148
149- def testModredTruncate (self , matarrayin ):
149+ def testModredTruncate (self ):
150150 #balanced realization computed in matlab for the transfer function:
151151 # num = [1 11 45 32], den = [1 15 60 200 60]
152- A = matarrayin (
152+ A = np . array (
153153 [[- 1.958 , - 1.194 , 1.824 , - 1.464 ],
154154 [- 1.194 , - 0.8344 , 2.563 , - 1.351 ],
155155 [- 1.824 , - 2.563 , - 1.124 , 2.704 ],
156156 [- 1.464 , - 1.351 , - 2.704 , - 11.08 ]])
157- B = matarrayin ([[- 0.9057 ], [- 0.4068 ], [- 0.3263 ], [- 0.3474 ]])
158- C = matarrayin ([[- 0.9057 , - 0.4068 , 0.3263 , - 0.3474 ]])
159- D = matarrayin ([[0. ]])
157+ B = np . array ([[- 0.9057 ], [- 0.4068 ], [- 0.3263 ], [- 0.3474 ]])
158+ C = np . array ([[- 0.9057 , - 0.4068 , 0.3263 , - 0.3474 ]])
159+ D = np . array ([[0. ]])
160160 sys = StateSpace (A , B , C , D )
161161 rsys = modred (sys ,[2 , 3 ],'truncate' )
162162 Artrue = np .array ([[- 1.958 , - 1.194 ], [- 1.194 , - 0.8344 ]])
@@ -170,18 +170,18 @@ def testModredTruncate(self, matarrayin):
170170
171171
172172 @slycotonly
173- def testBalredTruncate (self , matarrayin ):
173+ def testBalredTruncate (self ):
174174 # controlable canonical realization computed in matlab for the transfer
175175 # function:
176176 # num = [1 11 45 32], den = [1 15 60 200 60]
177- A = matarrayin (
177+ A = np . array (
178178 [[- 15. , - 7.5 , - 6.25 , - 1.875 ],
179179 [8. , 0. , 0. , 0. ],
180180 [0. , 4. , 0. , 0. ],
181181 [0. , 0. , 1. , 0. ]])
182- B = matarrayin ([[2. ], [0. ], [0. ], [0. ]])
183- C = matarrayin ([[0.5 , 0.6875 , 0.7031 , 0.5 ]])
184- D = matarrayin ([[0. ]])
182+ B = np . array ([[2. ], [0. ], [0. ], [0. ]])
183+ C = np . array ([[0.5 , 0.6875 , 0.7031 , 0.5 ]])
184+ D = np . array ([[0. ]])
185185
186186 sys = StateSpace (A , B , C , D )
187187 orders = 2
@@ -211,18 +211,18 @@ def testBalredTruncate(self, matarrayin):
211211 np .testing .assert_array_almost_equal (Dr , Drtrue , decimal = 4 )
212212
213213 @slycotonly
214- def testBalredMatchDC (self , matarrayin ):
214+ def testBalredMatchDC (self ):
215215 # controlable canonical realization computed in matlab for the transfer
216216 # function:
217217 # num = [1 11 45 32], den = [1 15 60 200 60]
218- A = matarrayin (
218+ A = np . array (
219219 [[- 15. , - 7.5 , - 6.25 , - 1.875 ],
220220 [8. , 0. , 0. , 0. ],
221221 [0. , 4. , 0. , 0. ],
222222 [0. , 0. , 1. , 0. ]])
223- B = matarrayin ([[2. ], [0. ], [0. ], [0. ]])
224- C = matarrayin ([[0.5 , 0.6875 , 0.7031 , 0.5 ]])
225- D = matarrayin ([[0. ]])
223+ B = np . array ([[2. ], [0. ], [0. ], [0. ]])
224+ C = np . array ([[0.5 , 0.6875 , 0.7031 , 0.5 ]])
225+ D = np . array ([[0. ]])
226226
227227 sys = StateSpace (A , B , C , D )
228228 orders = 2
0 commit comments