PythonLinearNonlinearControl icon indicating copy to clipboard operation
PythonLinearNonlinearControl copied to clipboard

Increase the usage of augmented assignment statements

Open elfring opened this issue 2 years ago • 0 comments

:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of augmented assignment statements accordingly.

diff --git a/PythonLinearNonlinearControl/controllers/mpc.py b/PythonLinearNonlinearControl/controllers/mpc.py
index c1e0db3..7f8c001 100644
--- a/PythonLinearNonlinearControl/controllers/mpc.py
+++ b/PythonLinearNonlinearControl/controllers/mpc.py
@@ -167,7 +167,7 @@ class LinearMPC(Controller):
 
         H = np.matmul(self.theta_mat.T, np.matmul(self.Qs, self.theta_mat)) \
             + self.Rs
-        H = H * 0.5
+        H *= 0.5
 
         # constraints
         A = []
diff --git a/PythonLinearNonlinearControl/controllers/nmpc_cgmres.py b/PythonLinearNonlinearControl/controllers/nmpc_cgmres.py
index 70e722b..74432af 100644
--- a/PythonLinearNonlinearControl/controllers/nmpc_cgmres.py
+++ b/PythonLinearNonlinearControl/controllers/nmpc_cgmres.py
@@ -126,7 +126,7 @@ class NMPCCGMRES(Controller):
 
             for j in range(i + 1):
                 hs[j, i] = np.dot(Av, vs[:, j])
-                sum_Av = sum_Av + hs[j, i] * vs[:, j]
+                sum_Av += hs[j, i] * vs[:, j]
 
             v_est = Av - sum_Av
 

elfring avatar Nov 02 '21 09:11 elfring