@@ -61,7 +61,7 @@ def test_linear_iosys(self, tsys):
61
61
62
62
# Make sure that simulations also line up
63
63
T , U , X0 = tsys .T , tsys .U , tsys .X0
64
- lti_t , lti_y , lti_x = ct .forced_response (linsys , T , U , X0 )
64
+ lti_t , lti_y = ct .forced_response (linsys , T , U , X0 )
65
65
ios_t , ios_y = ios .input_output_response (iosys , T , U , X0 )
66
66
np .testing .assert_array_almost_equal (lti_t , ios_t )
67
67
np .testing .assert_allclose (lti_y , ios_y , atol = 0.002 , rtol = 0. )
@@ -75,7 +75,7 @@ def test_tf2io(self, tsys):
75
75
76
76
# Verify correctness via simulation
77
77
T , U , X0 = tsys .T , tsys .U , tsys .X0
78
- lti_t , lti_y , lti_x = ct .forced_response (linsys , T , U , X0 )
78
+ lti_t , lti_y = ct .forced_response (linsys , T , U , X0 )
79
79
ios_t , ios_y = ios .input_output_response (iosys , T , U , X0 )
80
80
np .testing .assert_array_almost_equal (lti_t , ios_t )
81
81
np .testing .assert_allclose (lti_y , ios_y , atol = 0.002 , rtol = 0. )
@@ -84,7 +84,7 @@ def test_tf2io(self, tsys):
84
84
tfsys = ct .tf ('s' )
85
85
with pytest .raises (ValueError ):
86
86
iosys = ct .tf2io (tfsys )
87
-
87
+
88
88
def test_ss2io (self , tsys ):
89
89
# Create an input/output system from the linear system
90
90
linsys = tsys .siso_linsys
@@ -162,7 +162,7 @@ def test_nonlinear_iosys(self, tsys):
162
162
163
163
# Make sure that simulations also line up
164
164
T , U , X0 = tsys .T , tsys .U , tsys .X0
165
- lti_t , lti_y , lti_x = ct .forced_response (linsys , T , U , X0 )
165
+ lti_t , lti_y = ct .forced_response (linsys , T , U , X0 )
166
166
ios_t , ios_y = ios .input_output_response (nlsys , T , U , X0 )
167
167
np .testing .assert_array_almost_equal (lti_t , ios_t )
168
168
np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 ,rtol = 0. )
@@ -256,7 +256,7 @@ def test_connect(self, tsys):
256
256
X0 = np .concatenate ((tsys .X0 , tsys .X0 ))
257
257
ios_t , ios_y , ios_x = ios .input_output_response (
258
258
iosys_series , T , U , X0 , return_x = True )
259
- lti_t , lti_y , lti_x = ct .forced_response (linsys_series , T , U , X0 )
259
+ lti_t , lti_y = ct .forced_response (linsys_series , T , U , X0 )
260
260
np .testing .assert_array_almost_equal (lti_t , ios_t )
261
261
np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 ,rtol = 0. )
262
262
@@ -273,7 +273,7 @@ def test_connect(self, tsys):
273
273
assert ct .isctime (iosys_series , strict = True )
274
274
ios_t , ios_y , ios_x = ios .input_output_response (
275
275
iosys_series , T , U , X0 , return_x = True )
276
- lti_t , lti_y , lti_x = ct .forced_response (linsys_series , T , U , X0 )
276
+ lti_t , lti_y = ct .forced_response (linsys_series , T , U , X0 )
277
277
np .testing .assert_array_almost_equal (lti_t , ios_t )
278
278
np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 ,rtol = 0. )
279
279
@@ -288,7 +288,7 @@ def test_connect(self, tsys):
288
288
)
289
289
ios_t , ios_y , ios_x = ios .input_output_response (
290
290
iosys_feedback , T , U , X0 , return_x = True )
291
- lti_t , lti_y , lti_x = ct .forced_response (linsys_feedback , T , U , X0 )
291
+ lti_t , lti_y = ct .forced_response (linsys_feedback , T , U , X0 )
292
292
np .testing .assert_array_almost_equal (lti_t , ios_t )
293
293
np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 ,rtol = 0. )
294
294
@@ -325,7 +325,8 @@ def test_connect_spec_variants(self, tsys, connections, inplist, outlist):
325
325
# Create a simulation run to compare against
326
326
T , U = tsys .T , tsys .U
327
327
X0 = np .concatenate ((tsys .X0 , tsys .X0 ))
328
- lti_t , lti_y , lti_x = ct .forced_response (linsys_series , T , U , X0 )
328
+ lti_t , lti_y , lti_x = ct .forced_response (
329
+ linsys_series , T , U , X0 , return_x = True )
329
330
330
331
# Create the input/output system with different parameter variations
331
332
iosys_series = ios .InterconnectedSystem (
@@ -360,7 +361,8 @@ def test_connect_spec_warnings(self, tsys, connections, inplist, outlist):
360
361
# Create a simulation run to compare against
361
362
T , U = tsys .T , tsys .U
362
363
X0 = np .concatenate ((tsys .X0 , tsys .X0 ))
363
- lti_t , lti_y , lti_x = ct .forced_response (linsys_series , T , U , X0 )
364
+ lti_t , lti_y , lti_x = ct .forced_response (
365
+ linsys_series , T , U , X0 , return_x = True )
364
366
365
367
# Set up multiple gainst and make sure a warning is generated
366
368
with pytest .warns (UserWarning , match = "multiple.*Combining" ):
@@ -388,7 +390,8 @@ def test_static_nonlinearity(self, tsys):
388
390
389
391
# Make sure saturation works properly by comparing linear system with
390
392
# saturated input to nonlinear system with saturation composition
391
- lti_t , lti_y , lti_x = ct .forced_response (linsys , T , Usat , X0 )
393
+ lti_t , lti_y , lti_x = ct .forced_response (
394
+ linsys , T , Usat , X0 , return_x = True )
392
395
ios_t , ios_y , ios_x = ios .input_output_response (
393
396
ioslin * nlsat , T , U , X0 , return_x = True )
394
397
np .testing .assert_array_almost_equal (lti_t , ios_t )
@@ -424,7 +427,7 @@ def test_algebraic_loop(self, tsys):
424
427
# Nonlinear system composed with LTI system (series) -- with states
425
428
ios_t , ios_y = ios .input_output_response (
426
429
nlios * lnios * nlios , T , U , X0 )
427
- lti_t , lti_y , lti_x = ct .forced_response (linsys , T , U * U , X0 )
430
+ lti_t , lti_y , = ct .forced_response (linsys , T , U * U , X0 )
428
431
np .testing .assert_array_almost_equal (ios_y , lti_y * lti_y , decimal = 3 )
429
432
430
433
# Nonlinear system in feeback loop with LTI system
@@ -480,7 +483,7 @@ def test_summer(self, tsys):
480
483
U = [np .sin (T ), np .cos (T )]
481
484
X0 = 0
482
485
483
- lin_t , lin_y , lin_x = ct .forced_response (linsys_parallel , T , U , X0 )
486
+ lin_t , lin_y , = ct .forced_response (linsys_parallel , T , U , X0 )
484
487
ios_t , ios_y = ios .input_output_response (iosys_parallel , T , U , X0 )
485
488
np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 ,rtol = 0. )
486
489
@@ -502,7 +505,7 @@ def test_rmul(self, tsys):
502
505
503
506
# Make sure we got the right thing (via simulation comparison)
504
507
ios_t , ios_y = ios .input_output_response (sys2 , T , U , X0 )
505
- lti_t , lti_y , lti_x = ct .forced_response (ioslin , T , U * U , X0 )
508
+ lti_t , lti_y = ct .forced_response (ioslin , T , U * U , X0 )
506
509
np .testing .assert_array_almost_equal (ios_y , lti_y * lti_y , decimal = 3 )
507
510
508
511
@noscipy0
@@ -525,7 +528,7 @@ def test_neg(self, tsys):
525
528
526
529
# Make sure we got the right thing (via simulation comparison)
527
530
ios_t , ios_y = ios .input_output_response (sys , T , U , X0 )
528
- lti_t , lti_y , lti_x = ct .forced_response (ioslin , T , U * U , X0 )
531
+ lti_t , lti_y = ct .forced_response (ioslin , T , U * U , X0 )
529
532
np .testing .assert_array_almost_equal (ios_y , - lti_y , decimal = 3 )
530
533
531
534
@noscipy0
@@ -541,7 +544,7 @@ def test_feedback(self, tsys):
541
544
linsys = ct .feedback (tsys .siso_linsys , 1 )
542
545
543
546
ios_t , ios_y = ios .input_output_response (iosys , T , U , X0 )
544
- lti_t , lti_y , lti_x = ct .forced_response (linsys , T , U , X0 )
547
+ lti_t , lti_y = ct .forced_response (linsys , T , U , X0 )
545
548
np .testing .assert_allclose (ios_y , lti_y ,atol = 0.002 ,rtol = 0. )
546
549
547
550
@noscipy0
@@ -561,33 +564,33 @@ def test_bdalg_functions(self, tsys):
561
564
# Series interconnection
562
565
linsys_series = ct .series (linsys1 , linsys2 )
563
566
iosys_series = ct .series (linio1 , linio2 )
564
- lin_t , lin_y , lin_x = ct .forced_response (linsys_series , T , U , X0 )
567
+ lin_t , lin_y = ct .forced_response (linsys_series , T , U , X0 )
565
568
ios_t , ios_y = ios .input_output_response (iosys_series , T , U , X0 )
566
569
np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 ,rtol = 0. )
567
570
568
571
# Make sure that systems don't commute
569
572
linsys_series = ct .series (linsys2 , linsys1 )
570
- lin_t , lin_y , lin_x = ct .forced_response (linsys_series , T , U , X0 )
573
+ lin_t , lin_y = ct .forced_response (linsys_series , T , U , X0 )
571
574
assert not (np .abs (lin_y - ios_y ) < 1e-3 ).all ()
572
575
573
576
# Parallel interconnection
574
577
linsys_parallel = ct .parallel (linsys1 , linsys2 )
575
578
iosys_parallel = ct .parallel (linio1 , linio2 )
576
- lin_t , lin_y , lin_x = ct .forced_response (linsys_parallel , T , U , X0 )
579
+ lin_t , lin_y = ct .forced_response (linsys_parallel , T , U , X0 )
577
580
ios_t , ios_y = ios .input_output_response (iosys_parallel , T , U , X0 )
578
581
np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 ,rtol = 0. )
579
582
580
583
# Negation
581
584
linsys_negate = ct .negate (linsys1 )
582
585
iosys_negate = ct .negate (linio1 )
583
- lin_t , lin_y , lin_x = ct .forced_response (linsys_negate , T , U , X0 )
586
+ lin_t , lin_y = ct .forced_response (linsys_negate , T , U , X0 )
584
587
ios_t , ios_y = ios .input_output_response (iosys_negate , T , U , X0 )
585
588
np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 ,rtol = 0. )
586
589
587
590
# Feedback interconnection
588
591
linsys_feedback = ct .feedback (linsys1 , linsys2 )
589
592
iosys_feedback = ct .feedback (linio1 , linio2 )
590
- lin_t , lin_y , lin_x = ct .forced_response (linsys_feedback , T , U , X0 )
593
+ lin_t , lin_y = ct .forced_response (linsys_feedback , T , U , X0 )
591
594
ios_t , ios_y = ios .input_output_response (iosys_feedback , T , U , X0 )
592
595
np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 ,rtol = 0. )
593
596
@@ -614,13 +617,13 @@ def test_nonsquare_bdalg(self, tsys):
614
617
# Multiplication
615
618
linsys_multiply = linsys_3i2o * linsys_2i3o
616
619
iosys_multiply = iosys_3i2o * iosys_2i3o
617
- lin_t , lin_y , lin_x = ct .forced_response (linsys_multiply , T , U2 , X0 )
620
+ lin_t , lin_y = ct .forced_response (linsys_multiply , T , U2 , X0 )
618
621
ios_t , ios_y = ios .input_output_response (iosys_multiply , T , U2 , X0 )
619
622
np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 ,rtol = 0. )
620
623
621
624
linsys_multiply = linsys_2i3o * linsys_3i2o
622
625
iosys_multiply = iosys_2i3o * iosys_3i2o
623
- lin_t , lin_y , lin_x = ct .forced_response (linsys_multiply , T , U3 , X0 )
626
+ lin_t , lin_y = ct .forced_response (linsys_multiply , T , U3 , X0 )
624
627
ios_t , ios_y = ios .input_output_response (iosys_multiply , T , U3 , X0 )
625
628
np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 ,rtol = 0. )
626
629
@@ -633,7 +636,7 @@ def test_nonsquare_bdalg(self, tsys):
633
636
# Feedback
634
637
linsys_multiply = ct .feedback (linsys_3i2o , linsys_2i3o )
635
638
iosys_multiply = iosys_3i2o .feedback (iosys_2i3o )
636
- lin_t , lin_y , lin_x = ct .forced_response (linsys_multiply , T , U3 , X0 )
639
+ lin_t , lin_y = ct .forced_response (linsys_multiply , T , U3 , X0 )
637
640
ios_t , ios_y = ios .input_output_response (iosys_multiply , T , U3 , X0 )
638
641
np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 ,rtol = 0. )
639
642
@@ -655,7 +658,7 @@ def test_discrete(self, tsys):
655
658
656
659
# Simulate and compare to LTI output
657
660
ios_t , ios_y = ios .input_output_response (lnios , T , U , X0 )
658
- lin_t , lin_y , lin_x = ct .forced_response (linsys , T , U , X0 )
661
+ lin_t , lin_y = ct .forced_response (linsys , T , U , X0 )
659
662
np .testing .assert_allclose (ios_t , lin_t ,atol = 0.002 ,rtol = 0. )
660
663
np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 ,rtol = 0. )
661
664
@@ -671,7 +674,7 @@ def test_discrete(self, tsys):
671
674
672
675
# Simulate and compare to LTI output
673
676
ios_t , ios_y = ios .input_output_response (lnios , T , U , X0 )
674
- lin_t , lin_y , lin_x = ct .forced_response (linsys , T , U , X0 )
677
+ lin_t , lin_y = ct .forced_response (linsys , T , U , X0 )
675
678
np .testing .assert_allclose (ios_t , lin_t ,atol = 0.002 ,rtol = 0. )
676
679
np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 ,rtol = 0. )
677
680
@@ -839,7 +842,7 @@ def test_params(self, tsys):
839
842
linsys = tsys .siso_linsys
840
843
iosys = ios .LinearIOSystem (linsys )
841
844
T , U , X0 = tsys .T , tsys .U , tsys .X0
842
- lti_t , lti_y , lti_x = ct .forced_response (linsys , T , U , X0 )
845
+ lti_t , lti_y = ct .forced_response (linsys , T , U , X0 )
843
846
with pytest .warns (UserWarning , match = "LinearIOSystem.*ignored" ):
844
847
ios_t , ios_y = ios .input_output_response (
845
848
iosys , T , U , X0 , params = {'something' :0 })
0 commit comments