From 86b5bbda70009c386fc88668f40cc03c08c89981 Mon Sep 17 00:00:00 2001 From: Carl Sandrock Date: Sun, 29 Mar 2015 18:27:19 +0200 Subject: [PATCH] Removed redundant parentheses --- Chapter_05.py | 2 +- Chapter_06.py | 4 ++-- Exercise_06_08.py | 4 ++-- Figure_05_08.py | 2 +- Figure_05_09.py | 2 +- Figure_05_18.py | 6 +++--- Figure_08_16.py | 2 +- MIMOnyquist.py | 4 ++-- Nyquist_PM_GM.py | 4 ++-- SVD_w.py | 2 +- perturbed_models.py | 2 +- robusttools.py | 4 ++-- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Chapter_05.py b/Chapter_05.py index f40bb0d..7996060 100644 --- a/Chapter_05.py +++ b/Chapter_05.py @@ -376,7 +376,7 @@ def rule6(G, Gm, message=False): else: valid6 = False if message: - if (wz != 0): + if wz != 0: print 'These are the roots of the transfer function matrix GGm' , zeros if valid6: print 'The critical frequency of S for the system to be controllable is' , wz diff --git a/Chapter_06.py b/Chapter_06.py index 06f13b7..b4595fe 100644 --- a/Chapter_06.py +++ b/Chapter_06.py @@ -98,7 +98,7 @@ def Min_Peaks(Zeros_G, Poles_G, error_poles_direction, io_type, usedeadtime=Fals p_direction = np.matrix(np.zeros([G(0.001).shape[0], len(Poles_G)])) # error_poles_direction is to to prevent the numerical method from breaking - if (io_type == 'input'): + if io_type == 'input': for i in range(len(Zeros_G)): [U, S, V] = np.linalg.svd(G(Zeros_G[i]+error_poles_direction)) @@ -107,7 +107,7 @@ def Min_Peaks(Zeros_G, Poles_G, error_poles_direction, io_type, usedeadtime=Fals [U, S, V] = np.linalg.svd(G(Poles_G[i] + error_poles_direction)) p_direction[:, i] = U[:, 0] - elif (io_type == 'output'): + elif io_type == 'output': for i in range(len(Zeros_G)): [U, S, V] = np.linalg.svd(G(Zeros_G[i]+error_poles_direction)) diff --git a/Exercise_06_08.py b/Exercise_06_08.py index b97095b..6e4e74c 100644 --- a/Exercise_06_08.py +++ b/Exercise_06_08.py @@ -25,7 +25,7 @@ def g11(s): def g12(s): - return (1/(s**2 + 100)) + return 1/(s**2 + 100) def g21(s): @@ -33,7 +33,7 @@ def g21(s): def g22(s): - return (1/(s**2 + 100)) + return 1/(s**2 + 100) def lambda11(s): diff --git a/Figure_05_08.py b/Figure_05_08.py index 88472e3..9c518ea 100644 --- a/Figure_05_08.py +++ b/Figure_05_08.py @@ -6,6 +6,6 @@ #Figure 5.8 G = (-s + 1)/(s + 1) Kc = [0.1, 0.5, 0.9] -K = -1*(s)/((1 + 0.02*s)*(1 + 0.05*s)) +K = -1*s/((1 + 0.02*s)*(1 + 0.05*s)) utilsplot.freq_step_response_plot(G, K, Kc, 0.2, 1000, 'S', 'Figure 5.8') \ No newline at end of file diff --git a/Figure_05_09.py b/Figure_05_09.py index bcb15b3..6739c24 100644 --- a/Figure_05_09.py +++ b/Figure_05_09.py @@ -13,7 +13,7 @@ G = (1 - s)/(s + 1) for kc in [0.1, 0.5, 0.9]: - k1 = -1*kc*(s)/((1 + 0.02*s)*(1 + 0.05*s)) + k1 = -1*kc*s/((1 + 0.02*s)*(1 + 0.05*s)) L = G*k1 S = 1/(1 + L) plt.loglog(w, abs(S)) diff --git a/Figure_05_18.py b/Figure_05_18.py index 2a8e65c..076a547 100644 --- a/Figure_05_18.py +++ b/Figure_05_18.py @@ -75,11 +75,11 @@ plt.annotate('', (m2x, m2gd), (m2x, m2l), arrowprops=dict(arrowstyle='<->', shrinkA=0, shrinkB=0)) plt.annotate('$M_2$', (m2x + 25, abs(m2gd - m2l) / 1.5)) -if (wp != 0): +if wp != 0: plt.annotate('', (wp, 10**-2.5), (wc, 10**-2.5), arrowprops=dict(arrowstyle='<->', shrinkA=0, shrinkB=0)) plt.annotate('$M_3$', (abs(wc - wp) / 1.5, 10**-2.3)) -if (wz != 0): +if wz != 0: plt.annotate('', (wc, 10**-3.5), (wz, 10**-3.5), arrowprops=dict(arrowstyle='<->', shrinkA=0, shrinkB=0)) plt.annotate('$M_4$', (abs(wc - wz) / 3, 10**-3.3)) @@ -89,7 +89,7 @@ plt.annotate('', (0.001, 10**-2.5), (wd, 10**-2.5), arrowprops=dict(arrowstyle='<-', shrinkA=0, shrinkB=0)) plt.annotate('Control needed to reject disturbances', (0.0015, 10**-2.3)) -if (wtd != 0): +if wtd != 0: plt.annotate('', (wc, 10**-5.5), (wtd, 10**-5.5), arrowprops=dict(arrowstyle='<->', shrinkA=0, shrinkB=0)) plt.annotate('$M_6$', (abs(wc - wtd) / 8, 10**-5.3)) diff --git a/Figure_08_16.py b/Figure_08_16.py index 5ca6fa6..0915646 100644 --- a/Figure_08_16.py +++ b/Figure_08_16.py @@ -13,7 +13,7 @@ s = 1j*w Wi = (s + 0.2)/(0.5 * s + 1) -Wp = (s/2 + 0.05)/(s) +Wp = (s/2 + 0.05)/s plt.figure(1) plt.title('Weight Values over Frequency') diff --git a/MIMOnyquist.py b/MIMOnyquist.py index af37a5b..713f3e4 100644 --- a/MIMOnyquist.py +++ b/MIMOnyquist.py @@ -21,11 +21,11 @@ def G(s): - return(K*np.exp(-t1*s)/(t2*s + 1)) + return K*np.exp(-t1*s)/(t2*s + 1) def L(s): - return(Kc*G(s)) + return Kc*G(s) mino_nyquist_plot(L, 2, -3, 3) plt.show() diff --git a/Nyquist_PM_GM.py b/Nyquist_PM_GM.py index 16bb055..66b84d6 100644 --- a/Nyquist_PM_GM.py +++ b/Nyquist_PM_GM.py @@ -35,8 +35,8 @@ def mod(w): # plotting a unit circle x = np.linspace(-1, 1, 200) - y_upper = np.sqrt(1-(x)**2) - y_down = -1*np.sqrt(1-(x)**2) + y_upper = np.sqrt(1- x**2) + y_down = -1*np.sqrt(1- x**2) plt.plot(x, y_upper, 'r-', x, y_down, 'r-') plt.show() diff --git a/SVD_w.py b/SVD_w.py index 633177a..5a9c606 100644 --- a/SVD_w.py +++ b/SVD_w.py @@ -9,7 +9,7 @@ def G(w): s = w*1j # the matrix transfer function - G = [[1/(s+1), 1/(10*s+1)**2, 1], [0.4/((s)*(s+3)), -0.1/(s**2+1), 1], [1/(s+1), 10/(s+11), 1/(s+0.001)]] + G = [[1/(s+1), 1/(10*s+1)**2, 1], [0.4/(s*(s+3)), -0.1/(s**2+1), 1], [1/(s+1), 10/(s+11), 1/(s+0.001)]] return G diff --git a/perturbed_models.py b/perturbed_models.py index 74228b5..2fb8f74 100644 --- a/perturbed_models.py +++ b/perturbed_models.py @@ -72,7 +72,7 @@ def Gp(s, vec, i): def weight_i(s, a, b, c): """Function to give the weight of the uncertainty""" - w_i = (((s * a + start) / ((a / (end)) * s + 1)) + w_i = (((s * a + start) / ((a /end) * s + 1)) * ((s ** 2 + b * s + 1) / (s ** 2 + c * s + 1))) # w_i = ((((s * a + start) / ((a / (end)) * s + 1)) # * ((s ** 2 + b * s + 1) / (s ** 2 + c * s + 1))) diff --git a/robusttools.py b/robusttools.py index 32605a0..ce34e4d 100644 --- a/robusttools.py +++ b/robusttools.py @@ -24,11 +24,11 @@ def UnstructuredDelta(M, DeltaStructure): unstructured delta matrix ''' - if (DeltaStructure == "Full"): + if DeltaStructure == "Full": [U, s, V] = utils.SVD(M) S = np.diag(s) delta = 1/s[0] * V[:,0] * U[:,0].H - elif (DeltaStructure == 'Diagonal'): + elif DeltaStructure == 'Diagonal': # TODO: complete delta = 'NA' else: delta = 0