Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Increase the usage of augmented assignment statements #91

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

Increase the usage of augmented assignment statements #91

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/dpark/utils/tdigest.py b/dpark/utils/tdigest.py
index a0b4b7e..2369c10 100644
--- a/dpark/utils/tdigest.py
+++ b/dpark/utils/tdigest.py
@@ -97,8 +97,8 @@ class TDigest(object):
         def _argsort(seq):
             return sorted(range(len(seq)), key=seq.__getitem__)
 
-        incoming_weight = incoming_weight + self._weight
-        incoming_mean = incoming_mean + self._mean
+        incoming_weight += self._weight
+        incoming_mean += self._mean
 
         assert incoming_weight
 
@@ -121,7 +121,7 @@ class TDigest(object):
             q2 = (w_so_far + proposed_weight) / self._total_weight
             if z * z <= q0 * (1 - q0) and z * z <= q2 * (1 - q2):
                 weight[-1] += incoming_weight[ix]
-                mean[-1] = mean[-1] + (incoming_mean[ix] - mean[-1]) * incoming_weight[ix] / weight[-1]
+                mean[-1] += (incoming_mean[ix] - mean[-1]) * incoming_weight[ix] / weight[-1]
 
             else:
                 w_so_far += weight[-1]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant