@@ -194,50 +194,50 @@ def testLists(self):
194194 sys1_2 = ctrl .series (sys1 , sys2 )
195195 np .testing .assert_array_almost_equal (sort (pole (sys1_2 )), [- 4. , - 2. ])
196196 np .testing .assert_array_almost_equal (sort (zero (sys1_2 )), [- 3. , - 1. ])
197-
197+
198198 sys1_3 = ctrl .series (sys1 , sys2 , sys3 );
199199 np .testing .assert_array_almost_equal (sort (pole (sys1_3 )),
200200 [- 6. , - 4. , - 2. ])
201- np .testing .assert_array_almost_equal (sort (zero (sys1_3 )),
201+ np .testing .assert_array_almost_equal (sort (zero (sys1_3 )),
202202 [- 5. , - 3. , - 1. ])
203-
203+
204204 sys1_4 = ctrl .series (sys1 , sys2 , sys3 , sys4 );
205205 np .testing .assert_array_almost_equal (sort (pole (sys1_4 )),
206206 [- 8. , - 6. , - 4. , - 2. ])
207207 np .testing .assert_array_almost_equal (sort (zero (sys1_4 )),
208208 [- 7. , - 5. , - 3. , - 1. ])
209-
209+
210210 sys1_5 = ctrl .series (sys1 , sys2 , sys3 , sys4 , sys5 );
211211 np .testing .assert_array_almost_equal (sort (pole (sys1_5 )),
212212 [- 8. , - 6. , - 4. , - 2. , - 0. ])
213- np .testing .assert_array_almost_equal (sort (zero (sys1_5 )),
213+ np .testing .assert_array_almost_equal (sort (zero (sys1_5 )),
214214 [- 9. , - 7. , - 5. , - 3. , - 1. ])
215215
216- # Parallel
216+ # Parallel
217217 sys1_2 = ctrl .parallel (sys1 , sys2 )
218218 np .testing .assert_array_almost_equal (sort (pole (sys1_2 )), [- 4. , - 2. ])
219219 np .testing .assert_array_almost_equal (sort (zero (sys1_2 )),
220220 sort (zero (sys1 + sys2 )))
221-
221+
222222 sys1_3 = ctrl .parallel (sys1 , sys2 , sys3 );
223223 np .testing .assert_array_almost_equal (sort (pole (sys1_3 )),
224224 [- 6. , - 4. , - 2. ])
225- np .testing .assert_array_almost_equal (sort (zero (sys1_3 )),
225+ np .testing .assert_array_almost_equal (sort (zero (sys1_3 )),
226226 sort (zero (sys1 + sys2 + sys3 )))
227-
227+
228228 sys1_4 = ctrl .parallel (sys1 , sys2 , sys3 , sys4 );
229229 np .testing .assert_array_almost_equal (sort (pole (sys1_4 )),
230230 [- 8. , - 6. , - 4. , - 2. ])
231- np .testing .assert_array_almost_equal (sort (zero (sys1_4 )),
232- sort (zero (sys1 + sys2 +
231+ np .testing .assert_array_almost_equal (sort (zero (sys1_4 )),
232+ sort (zero (sys1 + sys2 +
233233 sys3 + sys4 )))
234234
235-
235+
236236 sys1_5 = ctrl .parallel (sys1 , sys2 , sys3 , sys4 , sys5 );
237237 np .testing .assert_array_almost_equal (sort (pole (sys1_5 )),
238238 [- 8. , - 6. , - 4. , - 2. , - 0. ])
239- np .testing .assert_array_almost_equal (sort (zero (sys1_5 )),
240- sort (zero (sys1 + sys2 +
239+ np .testing .assert_array_almost_equal (sort (zero (sys1_5 )),
240+ sort (zero (sys1 + sys2 +
241241 sys3 + sys4 + sys5 )))
242242 def testMimoSeries (self ):
243243 """regression: bdalg.series reverses order of arguments"""
@@ -274,44 +274,54 @@ def test_feedback_args(self):
274274
275275 def testConnect (self ):
276276 sys = append (self .sys2 , self .sys3 ) # two siso systems
277-
277+
278+ # should not raise error
279+ connect (sys , [[1 , 2 ], [2 , - 2 ]], [2 ], [1 , 2 ])
280+ connect (sys , [[1 , 2 ], [2 , 0 ]], [2 ], [1 , 2 ])
281+ connect (sys , [[1 , 2 , 0 ], [2 , - 2 , 1 ]], [2 ], [1 , 2 ])
282+ connect (sys , [[1 , 2 ], [2 , - 2 ]], [2 , 1 ], [1 ])
283+ sys3x3 = append (sys , self .sys3 ) # 3x3 mimo
284+ connect (sys3x3 , [[1 , 2 , 0 ], [2 , - 2 , 1 ], [3 , - 3 , 0 ]], [2 ], [1 , 2 ])
285+ connect (sys3x3 , [[1 , 2 , 0 ], [2 , - 2 , 1 ], [3 , - 3 , 0 ]], [1 , 2 , 3 ], [3 ])
286+ connect (sys3x3 , [[1 , 2 , 0 ], [2 , - 2 , 1 ], [3 , - 3 , 0 ]], [2 , 3 ], [2 , 1 ])
287+
278288 # feedback interconnection out of bounds: input too high
279- Q = [[1 , 3 ], [2 , - 2 ]]
280- with self .assertRaises (IndexError ) as context :
289+ Q = [[1 , 3 ], [2 , - 2 ]]
290+ with self .assertRaises (IndexError ):
281291 connect (sys , Q , [2 ], [1 , 2 ])
282292 # feedback interconnection out of bounds: input too low
283- Q = [[0 , 2 ], [2 , - 2 ]]
284- with self .assertRaises (IndexError ) as context :
293+ Q = [[0 , 2 ], [2 , - 2 ]]
294+ with self .assertRaises (IndexError ):
285295 connect (sys , Q , [2 ], [1 , 2 ])
286296
287297 # feedback interconnection out of bounds: output too high
288- Q = [[1 , 2 ], [2 , - 3 ]]
289- with self .assertRaises (IndexError ) as context :
298+ Q = [[1 , 2 ], [2 , - 3 ]]
299+ with self .assertRaises (IndexError ):
290300 connect (sys , Q , [2 ], [1 , 2 ])
291- Q = [[1 , 2 ], [2 , 4 ]]
292- with self .assertRaises (IndexError ) as context :
301+ Q = [[1 , 2 ], [2 , 4 ]]
302+ with self .assertRaises (IndexError ):
293303 connect (sys , Q , [2 ], [1 , 2 ])
294-
304+
295305 # input/output index testing
296306 Q = [[1 , 2 ], [2 , - 2 ]] # OK interconnection
297-
307+
298308 # input index is out of bounds: too high
299- with self .assertRaises (IndexError ) as context :
309+ with self .assertRaises (IndexError ):
300310 connect (sys , Q , [3 ], [1 , 2 ])
301311 # input index is out of bounds: too low
302- with self .assertRaises (IndexError ) as context :
312+ with self .assertRaises (IndexError ):
303313 connect (sys , Q , [0 ], [1 , 2 ])
304- with self .assertRaises (IndexError ) as context :
314+ with self .assertRaises (IndexError ):
305315 connect (sys , Q , [- 2 ], [1 , 2 ])
306316 # output index is out of bounds: too high
307- with self .assertRaises (IndexError ) as context :
317+ with self .assertRaises (IndexError ):
308318 connect (sys , Q , [2 ], [1 , 3 ])
309319 # output index is out of bounds: too low
310- with self .assertRaises (IndexError ) as context :
320+ with self .assertRaises (IndexError ):
311321 connect (sys , Q , [2 ], [1 , 0 ])
312- with self .assertRaises (IndexError ) as context :
322+ with self .assertRaises (IndexError ):
313323 connect (sys , Q , [2 ], [1 , - 1 ])
314-
324+
315325
316326if __name__ == "__main__" :
317327 unittest .main ()
0 commit comments