@@ -22,7 +22,7 @@ def _P(sys, indent='right'):
22
22
if indent == 'right' :
23
23
return (sys .pole ().real > 0 ).sum ()
24
24
elif indent == 'left' :
25
- return (sys .pole ().real < 0 ).sum ()
25
+ return (sys .pole ().real >= 0 ).sum ()
26
26
elif indent == 'none' :
27
27
if any (sys .pole ().real == 0 ):
28
28
raise ValueError ("indent must be left or right for imaginary pole" )
@@ -209,16 +209,33 @@ def test_nyquist_indent():
209
209
assert _Z (sys ) == count + _P (sys )
210
210
211
211
plt .figure ();
212
- count = ct .nyquist_plot (sys , indent_direction = 'right ' )
212
+ count = ct .nyquist_plot (sys , indent_direction = 'left ' )
213
213
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 )
215
224
assert _Z (sys ) == count + _P (sys )
216
225
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
217
234
plt .figure ();
218
235
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' )
220
237
plt .title (
221
- "Pole at origin ; indent_direction='none'; encirclements = %d" % count )
238
+ "Imaginary poles ; indent_direction='none'; encirclements = %d" % count )
222
239
assert _Z (sys ) == count + _P (sys )
223
240
224
241
@@ -269,8 +286,7 @@ def test_nyquist_exceptions():
269
286
270
287
print ("Unusual Nyquist plot" )
271
288
sys = ct .tf ([1 ], [1 , 3 , 2 ]) * ct .tf ([1 ], [1 , 0 , 1 ])
272
- print (sys )
273
- print ("Poles:" , sys .pole ())
274
289
plt .figure ()
290
+ plt .title ("Poles: %s" % np .array2string (sys .pole (), precision = 2 , separator = ',' ))
275
291
count = ct .nyquist_plot (sys )
276
292
assert _Z (sys ) == count + _P (sys )
0 commit comments