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 #19

Open
elfring opened this issue Oct 19, 2021 · 0 comments
Open

Increase the usage of augmented assignment statements #19

elfring opened this issue Oct 19, 2021 · 0 comments

Comments

@elfring
Copy link

elfring commented Oct 19, 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/Python/LeniaND.py b/Python/LeniaND.py
index 1c05acc..892d0f0 100644
--- a/Python/LeniaND.py
+++ b/Python/LeniaND.py
@@ -676,7 +676,7 @@ class Analyzer:
 
                 self.density_sum = np.sum(self.polar_density, axis=0)
                 if self.density_ema is not None:
-                    self.density_ema = self.density_ema + self.ema_alpha * (self.density_sum - self.density_ema)
+                    self.density_ema += self.ema_alpha * (self.density_sum - self.density_ema)
                 else:
                     self.density_ema = self.density_sum
 
diff --git a/Python/LeniaNDK.py b/Python/LeniaNDK.py
index 03373fe..8722d87 100644
--- a/Python/LeniaNDK.py
+++ b/Python/LeniaNDK.py
@@ -701,7 +701,7 @@ class Analyzer:
 
                 self.density_sum = np.sum(self.polar_density, axis=0)
                 if self.density_ema is not None:
-                    self.density_ema = self.density_ema + self.ema_alpha * (self.density_sum - self.density_ema)
+                    self.density_ema += self.ema_alpha * (self.density_sum - self.density_ema)
                 else:
                     self.density_ema = self.density_sum
 
diff --git a/Python/LeniaNDKC.py b/Python/LeniaNDKC.py
index 765e00f..038e096 100644
--- a/Python/LeniaNDKC.py
+++ b/Python/LeniaNDKC.py
@@ -751,7 +751,7 @@ class Analyzer:
 
                 self.density_sum = np.sum(self.polar_density, axis=0)
                 if self.density_ema is not None:
-                    self.density_ema = self.density_ema + self.ema_alpha * (self.density_sum - self.density_ema)
+                    self.density_ema += self.ema_alpha * (self.density_sum - self.density_ema)
                 else:
                     self.density_ema = self.density_sum
 
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