@@ -157,7 +157,7 @@ def _default_gains(num, den, xlim, ylim):
157157 open_loop_poles = den .roots
158158 open_loop_zeros = num .roots
159159
160- if (open_loop_zeros .size != 0 ) & (open_loop_zeros .size < open_loop_poles .size ):
160+ if (open_loop_zeros .size != 0 ) and (open_loop_zeros .size < open_loop_poles .size ):
161161 open_loop_zeros_xl = np .append (open_loop_zeros ,
162162 np .ones (open_loop_poles .size - open_loop_zeros .size ) * open_loop_zeros [- 1 ])
163163 mymat_xl = np .append (mymat , open_loop_zeros_xl )
@@ -191,12 +191,11 @@ def _default_gains(num, den, xlim, ylim):
191191 else :
192192 y_tolerance = 0.05 * (ylim [1 ] - ylim [0 ])
193193
194-
195194 tolerance = np .max ([x_tolerance , y_tolerance ])
196195 distance_points = np .abs (np .diff (mymat , axis = 0 ))
197196 indexes_too_far = np .where (distance_points > tolerance )
198197
199- while (indexes_too_far [0 ].size > 0 ) & (kvect .size < 5000 ):
198+ while (indexes_too_far [0 ].size > 0 ) and (kvect .size < 5000 ):
200199 for index in indexes_too_far [0 ]:
201200 new_gains = np .linspace (kvect [index ], kvect [index + 1 ], 5 )
202201 new_points = _RLFindRoots (num , den , new_gains [1 :4 ])
@@ -246,7 +245,7 @@ def _ax_lim(mymat):
246245
247246
248247def _k_max (num , den , real_break_points , k_break_points ):
249- """" Calculation the maximum gain for the root locus shown in tne figure"""
248+ """" Calculate the maximum gain for the root locus shown in the figure"""
250249 asymp_number = den .order - num .order
251250 singular_points = np .concatenate ((num .roots , den .roots ), axis = 0 )
252251 important_points = np .concatenate ((singular_points , real_break_points ), axis = 0 )
@@ -308,8 +307,8 @@ def _RLFindRoots(nump, denp, kvect):
308307 curpoly = denp + k * nump
309308 curroots = curpoly .r
310309 if len (curroots ) < denp .order :
311- curroots = np . insert ( curroots , len ( curroots ), np . inf ) # if i have less poles than open loop is because i
312- # have one in infinity
310+ # if I have fewer poles than open loop, it is because i have one at infinity
311+ curroots = np . insert ( curroots , len ( curroots ), np . inf )
313312
314313 curroots .sort ()
315314 roots .append (curroots )
@@ -355,7 +354,6 @@ def _sgrid_func(fig=None, zeta=None, wn=None):
355354 if fig is None :
356355 fig = pylab .gcf ()
357356 ax = fig .gca ()
358- ylocator = ax .get_yaxis ().get_major_locator ()
359357 xlocator = ax .get_xaxis ().get_major_locator ()
360358
361359 ylim = ax .get_ylim ()
@@ -368,7 +366,7 @@ def _sgrid_func(fig=None, zeta=None, wn=None):
368366
369367 angules = []
370368 for z in zeta :
371- if (z >= 1e-4 ) & (z <= 1 ):
369+ if (z >= 1e-4 ) and (z <= 1 ):
372370 angules .append (np .pi / 2 + np .arcsin (z ))
373371 else :
374372 zeta .remove (z )
@@ -430,7 +428,7 @@ def _default_wn(xloc, ylim):
430428 while np .abs (wn [0 ]) < ylim [1 ]:
431429 wn = np .insert (wn , 0 , wn [0 ]- sep )
432430
433- while len (wn )> 7 :
431+ while len (wn ) > 7 :
434432 wn = wn [0 :- 1 :2 ]
435433
436434 return wn
0 commit comments