8000 TST: added a test condition that expects the warning to be issued whe… · forgi86/python-control@81f9ee7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 81f9ee7

Browse files
committed
TST: added a test condition that expects the warning to be issued when the Nyquist frequency is reached
FIX: changed >= to > to issue Nyquist frequency warning
1 parent 7f5d66c commit 81f9ee7

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

control/freqplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,8 +1133,8 @@ def singular_values_plot(syslist, omega=None,
11331133
omega_sys = np.hstack((
11341134
omega_sys[omega_sys < nyquistfrq], nyquistfrq))
11351135
else:
1136-
if np.max(omega_sys) >= nyquistfrq:
1137-
warnings.warn("Specified frequency range is above Nyquist limit!")
1136+
if np.max(omega_sys) > nyquistfrq:
1137+
warnings.warn("evaluation above Nyquist frequency")
11381138

11391139
omega_complex = np.exp(1j * omega_sys * sys.dt)
11401140
else:

control/tests/freqresp_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,7 @@ def test_singular_values_plot_mpl_base(ss_mimo_ct, ss_mimo_dt):
619619
sys_ct = ss_mimo_ct.sys
620620
sys_dt = ss_mimo_dt.sys
621621
plt.figure()
622-
omega_all = np.logspace(-3, 2, 1000)
623-
singular_values_plot(sys_ct, omega_all, plot=True)
622+
singular_values_plot(sys_ct, plot=True)
624623
fig = plt.gcf()
625624
allaxes = fig.get_axes()
626625
assert(len(allaxes) == 1)
@@ -636,9 +635,11 @@ def test_singular_values_plot_mpl_base(ss_mimo_ct, ss_mimo_dt):
636635
def test_singular_values_plot_mpl_superimpose_nyq(ss_mimo_ct, ss_mimo_dt):
637636
sys_ct = ss_mimo_ct.sys
638637
sys_dt = ss_mimo_dt.sys
638+
omega_all = np.logspace(-3, 2, 1000)
639639
plt.figure()
640-
singular_values_plot(sys_ct, plot=True)
641-
singular_values_plot(sys_dt, plot=True)
640+
singular_values_plot(sys_ct, omega_all, plot=True)
641+
with pytest.warns(UserWarning):
642+
singular_values_plot(sys_dt, omega_all, plot=True)
642643
fig = plt.gcf()
643644
allaxes = fig.get_axes()
644645
assert(len(allaxes) == 1)

0 commit comments

Comments
 (0)
0