@@ -372,6 +372,29 @@ def test_nyquist_indent_im():
372372 assert _Z (sys ) == response .count + _P (sys )
373373
374374
375+ def test_nyquist_indent_near_imaginary_axis ():
376+ """Test indent direction for poles near the imaginary axis."""
377+ sys = ct .tf ([1 , 11 , 10 ], [0.01 , 1 , 0.01 , 1 ])
378+ omega = np .linspace (0 , 2 , 21 )
379+
380+ _ , contour_default = ct .nyquist_response (
381+ sys , omega , indent_radius = 0.1 , return_contour = True ,
382+ warn_encirclements = False )
383+ _ , contour_right = ct .nyquist_response (
384+ sys , omega , indent_radius = 0.1 , indent_direction = 'right' ,
385+ return_contour = True , warn_encirclements = False )
386+ _ , contour_left = ct .nyquist_response (
387+ sys , omega , indent_radius = 0.1 , indent_direction = 'left' ,
388+ return_contour = True , warn_encirclements = False )
389+
390+ # The pole near +1j has a small positive real part, so the default
391+ # behavior indents to the left. Explicit directions override this.
392+ pole_index = np .argmin (np .abs (contour_default .imag - 1 ))
393+ assert contour_default [pole_index ].real < 0
394+ assert contour_right [pole_index ].real > 0
395+ assert contour_left [pole_index ].real < 0
396+
397+
375398def test_nyquist_exceptions ():
376399 # MIMO not implemented
377400 sys = ct .rss (2 , 2 , 2 )
0 commit comments