9
9
10
10
from control import StateSpace , forced_response , tf , rss , c2d
11
11
from control .exception import ControlMIMONotImplemented
12
- from control .tests .conftest import slycotonly , matarrayin
12
+ from control .tests .conftest import slycotonly
13
13
from control .modelsimp import balred , hsvd , markov , modred
14
14
15
15
16
16
class TestModelsimp :
17
17
"""Test model reduction functions"""
18
18
19
19
@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. ]])
25
25
sys = StateSpace (A , B , C , D )
26
26
hsv = hsvd (sys )
27
27
hsvtrue = np .array ([24.42686 , 0.5731395 ]) # from MATLAB
@@ -32,8 +32,8 @@ def testHSVD(self, matarrayout, matarrayin):
32
32
assert isinstance (hsv , np .ndarray )
33
33
assert not isinstance (hsv , np .matrix )
34
34
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. ]])
37
37
Y = U
38
38
m = 3
39
39
H = markov (Y , U , m , transpose = False )
@@ -111,17 +111,17 @@ def testMarkovResults(self, k, m, n):
111
111
# for k=5, m=n=10: 0.015 %
112
112
np .testing .assert_allclose (Mtrue , Mcomp , rtol = 1e-6 , atol = 1e-8 )
113
113
114
- def testModredMatchDC (self , matarrayin ):
114
+ def testModredMatchDC (self ):
115
115
#balanced realization computed in matlab for the transfer function:
116
116
# num = [1 11 45 32], den = [1 15 60 200 60]
117
- A = matarrayin (
117
+ A = np . array (
118
118
[[- 1.958 , - 1.194 , 1.824 , - 1.464 ],
119
119
[- 1.194 , - 0.8344 , 2.563 , - 1.351 ],
120
120
[- 1.824 , - 2.563 , - 1.124 , 2.704 ],
121
121
[- 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. ]])
125
125
sys = StateSpace (A , B , C , D )
126
126
rsys = modred (sys ,[2 , 3 ],'matchdc' )
127
127
Artrue = np .array ([[- 4.431 , - 4.552 ], [- 4.552 , - 5.361 ]])
@@ -133,30 +133,30 @@ def testModredMatchDC(self, matarrayin):
133
133
np .testing .assert_array_almost_equal (rsys .C , Crtrue , decimal = 3 )
134
134
np .testing .assert_array_almost_equal (rsys .D , Drtrue , decimal = 2 )
135
135
136
- def testModredUnstable (self , matarrayin ):
136
+ def testModredUnstable (self ):
137
137
"""Check if an error is thrown when an unstable system is given"""
138
- A = matarrayin (
138
+ A = np . array (
139
139
[[4.5418 , 3.3999 , 5.0342 , 4.3808 ],
140
140
[0.3890 , 0.3599 , 0.4195 , 0.1760 ],
141
141
[- 4.2117 , - 3.2395 , - 4.6760 , - 4.2180 ],
142
142
[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 ]])
146
146
sys = StateSpace (A , B , C , D )
147
147
np .testing .assert_raises (ValueError , modred , sys , [2 , 3 ])
148
148
149
- def testModredTruncate (self , matarrayin ):
149
+ def testModredTruncate (self ):
150
150
#balanced realization computed in matlab for the transfer function:
151
151
# num = [1 11 45 32], den = [1 15 60 200 60]
152
- A = matarrayin (
152
+ A = np . array (
153
153
[[- 1.958 , - 1.194 , 1.824 , - 1.464 ],
154
154
[- 1.194 , - 0.8344 , 2.563 , - 1.351 ],
155
155
[- 1.824 , - 2.563 , - 1.124 , 2.704 ],
156
156
[- 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. ]])
160
160
sys = StateSpace (A , B , C , D )
161
161
rsys = modred (sys ,[2 , 3 ],'truncate' )
162
162
Artrue = np .array ([[- 1.958 , - 1.194 ], [- 1.194 , - 0.8344 ]])
@@ -170,18 +170,18 @@ def testModredTruncate(self, matarrayin):
170
170
171
171
172
172
@slycotonly
173
- def testBalredTruncate (self , matarrayin ):
173
+ def testBalredTruncate (self ):
174
174
# controlable canonical realization computed in matlab for the transfer
175
175
# function:
176
176
# num = [1 11 45 32], den = [1 15 60 200 60]
177
- A = matarrayin (
177
+ A = np . array (
178
178
[[- 15. , - 7.5 , - 6.25 , - 1.875 ],
179
179
[8. , 0. , 0. , 0. ],
180
180
[0. , 4. , 0. , 0. ],
181
181
[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. ]])
185
185
186
186
sys = StateSpace (A , B , C , D )
187
187
orders = 2
@@ -211,18 +211,18 @@ def testBalredTruncate(self, matarrayin):
211
211
np .testing .assert_array_almost_equal (Dr , Drtrue , decimal = 4 )
212
212
213
213
@slycotonly
214
- def testBalredMatchDC (self , matarrayin ):
214
+ def testBalredMatchDC (self ):
215
215
# controlable canonical realization computed in matlab for the transfer
216
216
# function:
217
217
# num = [1 11 45 32], den = [1 15 60 200 60]
218
- A = matarrayin (
218
+ A = np . array (
219
219
[[- 15. , - 7.5 , - 6.25 , - 1.875 ],
220
220
[8. , 0. , 0. , 0. ],
221
221
[0. , 4. , 0. , 0. ],
222
222
[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. ]])
226
226
227
227
sys = StateSpace (A , B , C , D )
228
228
orders = 2
0 commit comments