@@ -60,7 +60,7 @@ def test_linear_iosys(self):
60
60
lti_t , lti_y , lti_x = ct .forced_response (linsys , T , U , X0 )
61
61
ios_t , ios_y = ios .input_output_response (iosys , T , U , X0 )
62
62
np .testing .assert_array_almost_equal (lti_t , ios_t )
63
- np .testing .assert_array_almost_equal (lti_y , ios_y , decimal = 3 )
63
+ np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 , rtol = 0. )
64
64
65
65
@unittest .skipIf (StrictVersion (sp .__version__ ) < "1.0" ,
66
66
"requires SciPy 1.0 or greater" )
@@ -75,7 +75,7 @@ def test_tf2io(self):
75
75
lti_t , lti_y , lti_x = ct .forced_response (linsys , T , U , X0 )
76
76
ios_t , ios_y = ios .input_output_response (iosys , T , U , X0 )
77
77
np .testing .assert_array_almost_equal (lti_t , ios_t )
78
- np .testing .assert_array_almost_equal (lti_y , ios_y , decimal = 3 )
78
+ np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 , rtol = 0. )
79
79
80
80
def test_ss2io (self ):
81
81
# Create an input/output system from the linear system
@@ -161,7 +161,7 @@ def test_nonlinear_iosys(self):
161
161
lti_t , lti_y , lti_x = ct .forced_response (linsys , T , U , X0 )
162
162
ios_t , ios_y = ios .input_output_response (nlsys , T , U , X0 )
163
163
np .testing .assert_array_almost_equal (lti_t , ios_t )
164
- np .testing .assert_array_almost_equal (lti_y , ios_y , decimal = 3 )
164
+ np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 , rtol = 0. )
165
165
166
166
def test_linearize (self ):
167
167
# Create a single input/single output linear system
@@ -214,7 +214,7 @@ def test_connect(self):
214
214
iosys_series , T , U , X0 , return_x = True )
215
215
lti_t , lti_y , lti_x = ct .forced_response (linsys_series , T , U , X0 )
216
216
np .testing .assert_array_almost_equal (lti_t , ios_t )
217
- np .testing .assert_array_almost_equal (lti_y , ios_y , decimal = 3 )
217
+ np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 , rtol = 0. )
218
218
219
219
# Connect systems with different timebases
220
220
linsys2c = self .siso_linsys
@@ -231,7 +231,7 @@ def test_connect(self):
231
231
iosys_series , T , U , X0 , return_x = True )
232
232
lti_t , lti_y , lti_x = ct .forced_response (linsys_series , T , U , X0 )
233
233
np .testing .assert_array_almost_equal (lti_t , ios_t )
234
- np .testing .assert_array_almost_equal (lti_y , ios_y , decimal = 3 )
234
+ np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 , rtol = 0. )
235
235
236
236
# Feedback interconnection
237
237
linsys_feedback = ct .feedback (linsys1 , linsys2 )
@@ -246,7 +246,7 @@ def test_connect(self):
246
246
iosys_feedback , T , U , X0 , return_x = True )
247
247
lti_t , lti_y , lti_x = ct .forced_response (linsys_feedback , T , U , X0 )
248
248
np .testing .assert_array_almost_equal (lti_t , ios_t )
249
- np .testing .assert_array_almost_equal (lti_y , ios_y , decimal = 3 )
249
+ np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 , rtol = 0. )
250
250
251
251
@unittest .skipIf (StrictVersion (sp .__version__ ) < "1.0" ,
252
252
"requires SciPy 1.0 or greater" )
@@ -357,7 +357,7 @@ def test_summer(self):
357
357
358
358
lin_t , lin_y , lin_x = ct .forced_response (linsys_parallel , T , U , X0 )
359
359
ios_t , ios_y = ios .input_output_response (iosys_parallel , T , U , X0 )
360
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
360
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
361
361
362
362
@unittest .skipIf (StrictVersion (sp .__version__ ) < "1.0" ,
363
363
"requires SciPy 1.0 or greater" )
@@ -420,7 +420,7 @@ def test_feedback(self):
420
420
421
421
ios_t , ios_y = ios .input_output_response (iosys , T , U , X0 )
422
422
lti_t , lti_y , lti_x = ct .forced_response (linsys , T , U , X0 )
423
- np .testing .assert_array_almost_equal (ios_y , lti_y , decimal = 3 )
423
+ np .testing .assert_allclose (ios_y , lti_y ,atol = 0.002 , rtol = 0. )
424
424
425
425
@unittest .skipIf (StrictVersion (sp .__version__ ) < "1.0" ,
426
426
"requires SciPy 1.0 or greater" )
@@ -442,7 +442,7 @@ def test_bdalg_functions(self):
442
442
iosys_series = ct .series (linio1 , linio2 )
443
443
lin_t , lin_y , lin_x = ct .forced_response (linsys_series , T , U , X0 )
444
444
ios_t , ios_y = ios .input_output_response (iosys_series , T , U , X0 )
445
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
445
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
446
446
447
447
# Make sure that systems don't commute
448
448
linsys_series = ct .series (linsys2 , linsys1 )
@@ -454,21 +454,21 @@ def test_bdalg_functions(self):
454
454
iosys_parallel = ct .parallel (linio1 , linio2 )
455
455
lin_t , lin_y , lin_x = ct .forced_response (linsys_parallel , T , U , X0 )
456
456
ios_t , ios_y = ios .input_output_response (iosys_parallel , T , U , X0 )
457
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
457
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
458
458
459
459
# Negation
460
460
linsys_negate = ct .negate (linsys1 )
461
461
iosys_negate = ct .negate (linio1 )
462
462
lin_t , lin_y , lin_x = ct .forced_response (linsys_negate , T , U , X0 )
463
463
ios_t , ios_y = ios .input_output_response (iosys_negate , T , U , X0 )
464
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
464
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
465
465
466
466
# Feedback interconnection
467
467
linsys_feedback = ct .feedback (linsys1 , linsys2 )
468
468
iosys_feedback = ct .feedback (linio1 , linio2 )
469
469
lin_t , lin_y , lin_x = ct .forced_response (linsys_feedback , T , U , X0 )
470
470
ios_t , ios_y = ios .input_output_response (iosys_feedback , T , U , X0 )
471
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
471
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
472
472
473
473
@unittest .skipIf (StrictVersion (sp .__version__ ) < "1.0" ,
474
474
"requires SciPy 1.0 or greater" )
@@ -496,26 +496,26 @@ def test_nonsquare_bdalg(self):
496
496
iosys_multiply = iosys_3i2o * iosys_2i3o
497
497
lin_t , lin_y , lin_x = ct .forced_response (linsys_multiply , T , U2 , X0 )
498
498
ios_t , ios_y = ios .input_output_response (iosys_multiply , T , U2 , X0 )
499
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
499
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
500
500
501
501
linsys_multiply = linsys_2i3o * linsys_3i2o
502
502
iosys_multiply = iosys_2i3o * iosys_3i2o
503
503
lin_t , lin_y , lin_x = ct .forced_response (linsys_multiply , T , U3 , X0 )
504
504
ios_t , ios_y = ios .input_output_response (iosys_multiply , T , U3 , X0 )
505
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
505
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
506
506
507
507
# Right multiplication
508
508
# TODO: add real tests once conversion from other types is supported
509
509
iosys_multiply = ios .InputOutputSystem .__rmul__ (iosys_3i2o , iosys_2i3o )
510
510
ios_t , ios_y = ios .input_output_response (iosys_multiply , T , U3 , X0 )
511
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
511
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
512
512
513
513
# Feedback
514
514
linsys_multiply = ct .feedback (linsys_3i2o , linsys_2i3o )
515
515
iosys_multiply = iosys_3i2o .feedback (iosys_2i3o )
516
516
lin_t , lin_y , lin_x = ct .forced_response (linsys_multiply , T , U3 , X0 )
517
517
ios_t , ios_y = ios .input_output_response (iosys_multiply , T , U3 , X0 )
518
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
518
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
519
519
520
520
# Mismatch should generate exception
521
521
args = (iosys_3i2o , iosys_3i2o )
@@ -536,8 +536,8 @@ def test_discrete(self):
536
536
# Simulate and compare to LTI output
537
537
ios_t , ios_y = ios .input_output_response (lnios , T , U , X0 )
538
538
lin_t , lin_y , lin_x = ct .forced_response (linsys , T , U , X0 )
539
- np .testing .assert_array_almost_equal (ios_t , lin_t , decimal = 3 )
540
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
539
+ np .testing .assert_allclose (ios_t , lin_t ,atol = 0.002 , rtol = 0. )
540
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
541
541
542
542
# Test MIMO system, converted to discrete time
543
543
linsys = ct .StateSpace (self .mimo_linsys1 )
@@ -552,8 +552,8 @@ def test_discrete(self):
552
552
# Simulate and compare to LTI output
553
553
ios_t , ios_y = ios .input_output_response (lnios , T , U , X0 )
554
554
lin_t , lin_y , lin_x = ct .forced_response (linsys , T , U , X0 )
555
- np .testing .assert_array_almost_equal (ios_t , lin_t , decimal = 3 )
556
- np .testing .assert_array_almost_equal (ios_y , lin_y , decimal = 3 )
555
+ np .testing .assert_allclose (ios_t , lin_t ,atol = 0.002 , rtol = 0. )
556
+ np .testing .assert_allclose (ios_y , lin_y ,atol = 0.002 , rtol = 0. )
557
557
558
558
def test_find_eqpts (self ):
559
559
"""Test find_eqpt function"""
@@ -738,7 +738,7 @@ def test_params(self):
738
738
739
739
# Check to make sure results are OK
740
740
np .testing .assert_array_almost_equal (lti_t , ios_t )
741
- np .testing .assert_array_almost_equal (lti_y , ios_y , decimal = 3 )
741
+ np .testing .assert_allclose (lti_y , ios_y ,atol = 0.002 , rtol = 0. )
742
742
743
743
def test_named_signals (self ):
744
744
sys1 = ios .NonlinearIOSystem (
0 commit comments