Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the usage of augmented assignment statements #18

Open
elfring opened this issue Nov 2, 2021 · 0 comments
Open

Increase the usage of augmented assignment statements #18

elfring opened this issue Nov 2, 2021 · 0 comments

Comments

@elfring
Copy link

elfring commented Nov 2, 2021

👀 Some source code analysis tools can help to find opportunities for improving software components.
💭 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
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant