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

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

Increase the usage of augmented assignment statements #143

elfring opened this issue Nov 13, 2021 · 0 comments

Comments

@elfring
Copy link

elfring commented Nov 13, 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/geomdl/CPGen.py b/geomdl/CPGen.py
index e63112d..a0b235a 100644
--- a/geomdl/CPGen.py
+++ b/geomdl/CPGen.py
@@ -106,11 +106,11 @@ class Grid(object):
                 # Add the first point
                 row.append([current_x, current_y, self._z_value])
                 # Set the y value for the next row
-                current_y = current_y + spacing_y
+                current_y += spacing_y
             # Update the list to be returned
             self._grid_points.append(row)
             # Set x the value for the next column
-            current_x = current_x + spacing_x
+            current_x += spacing_x
 
         # Set class variables
         self._size_u = num_u
@@ -194,7 +194,7 @@ class Grid(object):
                     trials = max_trials + 1  # set number of trials to a big value
                     break
                 else:
-                    trials = trials + 1
+                    trials += 1
             if trials == max_trials:
                 raise RuntimeError("Cannot generate %d bumps with a base extent of %d on this grid. "
                                    "You need to generate a grid larger than %dx%d."
diff --git a/geomdl/helpers.py b/geomdl/helpers.py
index 98dfe9d..4408fb0 100644
--- a/geomdl/helpers.py
+++ b/geomdl/helpers.py
@@ -938,7 +938,7 @@ def knot_refinement(degree, knotvector, ctrlpts, **kwargs):
             if abs(alpha) < tol:
                 new_ctrlpts[idx - 1] = deepcopy(new_ctrlpts[idx])
             else:
-                alpha = alpha / (new_kv[k + l] - knotvector[i - degree + l])
+                alpha /= new_kv[k + l] - knotvector[i - degree + l]
                 if isinstance(ctrlpts[0][0], float):
                     new_ctrlpts[idx - 1] = [alpha * p1 + (1.0 - alpha) * p2 for p1, p2 in
                                             zip(new_ctrlpts[idx - 1], new_ctrlpts[idx])]
@@ -947,7 +947,7 @@ def knot_refinement(degree, knotvector, ctrlpts, **kwargs):
                         new_ctrlpts[idx - 1][idx2] = [alpha * p1 + (1.0 - alpha) * p2 for p1, p2 in
                                                       zip(new_ctrlpts[idx - 1][idx2], new_ctrlpts[idx][idx2])]
         new_kv[k] = X[j]
-        k = k - 1
+        k -= 1
         j -= 1
 
     # Return control points and knot vector after refinement
diff --git a/geomdl/multi.py b/geomdl/multi.py
index a7f98f6..2f04e56 100644
--- a/geomdl/multi.py
+++ b/geomdl/multi.py
@@ -425,7 +425,7 @@ class CurveContainer(AbstractContainer):
 
             # Fix element name
             if elem.name == "curve":
-                elem.name = elem.name + " " + str(idx)
+                elem.name += " " + str(idx)
 
             # Color selection
             color = select_color(cpcolor, evalcolor, idx=idx)
@@ -1057,7 +1057,7 @@ class VolumeContainer(AbstractContainer):
 
             # Fix element name
             if elem.name == "volume":
-                elem.name = elem.name + " " + str(idx)
+                elem.name += " " + str(idx)
 
             # Color selection
             color = select_color(cpcolor, evalcolor, idx=idx)
@@ -1181,7 +1181,7 @@ def process_elements_surface(elem, mconf, colorval, idx, force_tsl, update_delta
 
     # Fix element name
     if elem.name == "surface" and idx >= 0:
-        elem.name = elem.name + " " + str(idx)
+        elem.name += " " + str(idx)
 
     # Color selection
     color = select_color(colorval[0], colorval[1], idx=idx)
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