@@ -22,7 +22,7 @@ def _P(sys, indent='right'):
2222 if indent == 'right' :
2323 return (sys .pole ().real > 0 ).sum ()
2424 elif indent == 'left' :
25- return (sys .pole ().real < 0 ).sum ()
25+ return (sys .pole ().real >= 0 ).sum ()
2626 elif indent == 'none' :
2727 if any (sys .pole ().real == 0 ):
2828 raise ValueError ("indent must be left or right for imaginary pole" )
@@ -209,16 +209,33 @@ def test_nyquist_indent():
209209 assert _Z (sys ) == count + _P (sys )
210210
211211 plt .figure ();
212- count = ct .nyquist_plot (sys , indent_direction = 'right ' )
212+ count = ct .nyquist_plot (sys , indent_direction = 'left ' )
213213 plt .title (
214- "Pole at origin; indent_direction='right'; encirclements = %d" % count )
214+ "Pole at origin; indent_direction='left'; encirclements = %d" % count )
215+ assert _Z (sys ) == count + _P (sys , indent = 'left' )
216+
217+ # System with poles on the imaginary axis
218+ sys = ct .tf ([1 , 1 ], [1 , 0 , 1 ])
219+
220+ # Imaginary poles with standard indentation
221+ plt .figure ();
222+ count = ct .nyquist_plot (sys )
223+ plt .title ("Imaginary poles; encirclements = %d" % count )
215224 assert _Z (sys ) == count + _P (sys )
216225
226+ # Imaginary poles with indentation to the left
227+ plt .figure ();
228+ count = ct .nyquist_plot (sys , indent_direction = 'left' , label_freq = 300 )
229+ plt .title (
230+ "Imaginary poles; indent_direction='left'; encirclements = %d" % count )
231+ assert _Z (sys ) == count + _P (sys , indent = 'left' )
232+
233+ # Imaginary poles with no indentation
217234 plt .figure ();
218235 count = ct .nyquist_plot (
219- sys , omega_limits = [ 1e-2 , 1e-3 ] , indent_direction = 'none' )
236+ sys , np . linspace ( 0 , 1e3 , 1000 ) , indent_direction = 'none' )
220237 plt .title (
221- "Pole at origin ; indent_direction='none'; encirclements = %d" % count )
238+ "Imaginary poles ; indent_direction='none'; encirclements = %d" % count )
222239 assert _Z (sys ) == count + _P (sys )
223240
224241
@@ -269,8 +286,7 @@ def test_nyquist_exceptions():
269286
270287print ("Unusual Nyquist plot" )
271288sys = ct .tf ([1 ], [1 , 3 , 2 ]) * ct .tf ([1 ], [1 , 0 , 1 ])
272- print (sys )
273- print ("Poles:" , sys .pole ())
274289plt .figure ()
290+ plt .title ("Poles: %s" % np .array2string (sys .pole (), precision = 2 , separator = ',' ))
275291count = ct .nyquist_plot (sys )
276292assert _Z (sys ) == count + _P (sys )
0 commit comments