Skip to content

Commit 19801e6

Browse files
committed
split up nyquist indent tests
1 parent 58d8cd6 commit 19801e6

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

control/tests/nyquist_test.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,42 +182,56 @@ def test_nyquist_encirclements():
182182
assert _Z(sys) == count + _P(sys)
183183

184184

185-
def test_nyquist_indent():
185+
@pytest.fixture
186+
def indentsys():
186187
# FBS Figure 10.10
187-
s = ct.tf('s')
188-
sys = 3 * (s+6)**2 / (s * (s+1)**2)
189188
# poles: [-1, -1, 0]
189+
s = ct.tf('s')
190+
return 3 * (s+6)**2 / (s * (s+1)**2)
190191

192+
193+
def test_nyquist_indent_default(indentsys):
191194
plt.figure();
192-
count = ct.nyquist_plot(sys)
195+
count = ct.nyquist_plot(indentsys)
193196
plt.title("Pole at origin; indent_radius=default")
194-
assert _Z(sys) == count + _P(sys)
197+
assert _Z(indentsys) == count + _P(indentsys)
195198

199+
200+
def test_nyquist_indent_dont(indentsys):
196201
# first value of default omega vector was 0.1, replaced by 0. for contour
197202
# indent_radius is larger than 0.1 -> no extra quater circle around origin
198-
count, contour = ct.nyquist_plot(sys, plot=False, indent_radius=.1007,
203+
count, contour = ct.nyquist_plot(indentsys,
204+
plot=False,
205+
indent_radius=.1007,
199206
return_contour=True)
200207
np.testing.assert_allclose(contour[0], .1007+0.j)
201208
# second value of omega_vector is larger than indent_radius: not indented
202209
assert np.all(contour.real[2:] == 0.)
203210

211+
212+
def test_nyquist_indent_do(indentsys):
204213
plt.figure();
205-
count, contour = ct.nyquist_plot(sys, indent_radius=0.01,
214+
count, contour = ct.nyquist_plot(indentsys,
215+
indent_radius=0.01,
206216
return_contour=True)
207217
plt.title("Pole at origin; indent_radius=0.01; encirclements = %d" % count)
208-
assert _Z(sys) == count + _P(sys)
218+
assert _Z(indentsys) == count + _P(indentsys)
209219
# indent radius is smaller than the start of the default omega vector
210220
# check that a quarter circle around the pole at origin has been added.
211221
np.testing.assert_allclose(contour[:50].real**2 + contour[:50].imag**2,
212222
0.01**2)
213223

224+
225+
def test_nyquist_indent_left(indentsys):
214226
plt.figure();
215-
count = ct.nyquist_plot(sys, indent_direction='left')
227+
count = ct.nyquist_plot(indentsys, indent_direction='left')
216228
plt.title(
217229
"Pole at origin; indent_direction='left'; encirclements = %d" % count)
218-
assert _Z(sys) == count + _P(sys, indent='left')
230+
assert _Z(indentsys) == count + _P(indentsys, indent='left')
231+
219232

220-
# System with poles on the imaginary axis
233+
def test_nyquist_indent_im():
234+
"""Test system with poles on the imaginary axis."""
221235
sys = ct.tf([1, 1], [1, 0, 1])
222236

223237
# Imaginary poles with standard indentation

0 commit comments

Comments
 (0)