@@ -435,24 +435,38 @@ def test_dcgain_consistency():
435
435
assert 0 in sys_tf .pole ()
436
436
assert 0 in sys_tf .zero ()
437
437
438
- sys_ss = ctrl .tf2ss (ctrl .tf ([1 , 0 ], [1 , 1 ])) * \
439
- ctrl .tf2ss (ctrl .tf ([1 ], [1 , 0 ]))
440
- assert 0 in sys_ss .pole ()
441
- assert 0 in sys_ss .zero ()
442
-
443
438
# Pole and zero at the origin should give nan + nanj for the response
444
439
np .testing .assert_equal (
445
440
sys_tf (0 , warn_infinite = False ), complex (np .nan , np .nan ))
446
441
np .testing .assert_equal (
447
442
sys_tf (0j , warn_infinite = False ), complex (np .nan , np .nan ))
448
443
np .testing .assert_equal (
449
444
sys_tf .dcgain (warn_infinite = False ), complex (np .nan , np .nan ))
450
- np .testing .assert_equal (
451
- sys_ss (0 , warn_infinite = False ), complex (np .nan , np .nan ))
452
- np .testing .assert_equal (
453
- sys_ss (0j , warn_infinite = False ), complex (np .nan , np .nan ))
454
- np .testing .assert_equal (
455
- sys_ss .dcgain (warn_infinite = False ), complex (np .nan , np .nan ))
445
+
446
+ # Set up state space version
447
+ sys_ss = ctrl .tf2ss (ctrl .tf ([1 , 0 ], [1 , 1 ])) * \
448
+ ctrl .tf2ss (ctrl .tf ([1 ], [1 , 0 ]))
449
+
450
+ # Different systems give different representations => test accordingly
451
+ if 0 in sys_ss .pole () and 0 in sys_ss .zero ():
452
+ # Pole and zero at the origin => should get (nan + nanj)
453
+ np .testing .assert_equal (
454
+ sys_ss (0 , warn_infinite = False ), complex (np .nan , np .nan ))
455
+ np .testing .assert_equal (
456
+ sys_ss (0j , warn_infinite = False ), complex (np .nan , np .nan ))
457
+ np .testing .assert_equal (
458
+ sys_ss .dcgain (warn_infinite = False ), complex (np .nan , np .nan ))
459
+ elif 0 in sys_ss .pole ():
460
+ # Pole at the origin, but zero elsewhere => should get (inf + nanj)
461
+ np .testing .assert_equal (
462
+ sys_ss (0 , warn_infinite = False ), complex (np .inf , np .nan ))
463
+ np .testing .assert_equal (
464
+ sys_ss (0j , warn_infinite = False ), complex (np .inf , np .nan ))
465
+ np .testing .assert_equal (
466
+ sys_ss .dcgain (warn_infinite = False ), complex (np .inf , np .nan ))
467
+ else :
468
+ # Near pole/zero cancellation => nothing sensible to check
469
+ pass
456
470
457
471
# Pole with non-zero, complex numerator => inf + infj
458
472
s = ctrl .tf ('s' )
0 commit comments