8000 add logic for pole/zero inaccuracies on different systems · python-control/python-control@223d0c8 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 223d0c8

Browse files
committed
add logic for pole/zero inaccuracies on different systems
1 parent 8b44e87 commit 223d0c8

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

control/tests/freqresp_test.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -435,24 +435,38 @@ def test_dcgain_consistency():
435435
assert 0 in sys_tf.pole()
436436
assert 0 in sys_tf.zero()
437437

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-
443438
# Pole and zero at the origin should give nan + nanj for the response
444439
np.testing.assert_equal(
445440
sys_tf(0, warn_infinite=False), complex(np.nan, np.nan))
446441
np.testing.assert_equal(
447442
sys_tf(0j, warn_infinite=False), complex(np.nan, np.nan))
448443
np.testing.assert_equal(
449444
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
456470

457471
# Pole with non-zero, complex numerator => inf + infj
458472
s = ctrl.tf('s')

0 commit comments

Comments
 (0)
0