[tor-commits] [sbws/maint-1.1] fix: scaling: Return if there are no measurements

juga at torproject.org juga at torproject.org
Tue Mar 16 14:17:53 UTC 2021


commit 455a7f69a9f3d0b2945a428e55e4eed604031e4e
Author: juga0 <juga at riseup.net>
Date:   Mon Mar 1 19:04:34 2021 +0000

    fix: scaling: Return if there are no measurements
    
    it should not be the case because the measurements come from
    successful results, but otherwise it'd throw an exception.
---
 sbws/lib/scaling.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/sbws/lib/scaling.py b/sbws/lib/scaling.py
index 6ec8185..4b21e79 100644
--- a/sbws/lib/scaling.py
+++ b/sbws/lib/scaling.py
@@ -14,11 +14,13 @@ def bw_filt(bw_measurements):
     It is the equivalent to Torflow's ``filt_sbw``.
     ``mu`` in this function is the equivalent to Torflow's ``sbw``.
     """
-    mu = 1
-    if bw_measurements:
-        # Torflow is rounding to an integer, so is `bw_mean_from_results` in
-        # `v3bwfile.py`
-        mu = round(mean(bw_measurements))
+    # This should never be the case, as the measurements come from successful
+    # results.
+    if not bw_measurements:
+        return 1
+    # Torflow is rounding to an integer, so is `bw_mean_from_results` in
+    # `v3bwfile.py`
+    mu = round(mean(bw_measurements))
     bws_gte_mean = list(filter(lambda bw: bw >= mu, bw_measurements))
     if bws_gte_mean:
         return round(mean(bws_gte_mean))





More information about the tor-commits mailing list