commit c57ba63ed0107e2ae07271302cfa7c9530774043 Author: juga0 juga@riseup.net Date: Fri Nov 23 17:40:23 2018 +0000
generate: use round_digs variable name in methods
The torflow-round-digs cli argument was kept, but it was added other argument, round-digs, for the same option. argparse takes the first argument as the variable name, but the methods where still using torflow_round_digs.
Closes bug #28602. Bugfix 1.0.3-dev0. --- sbws/core/generate.py | 2 +- sbws/lib/v3bwfile.py | 4 ++-- tests/unit/lib/test_v3bwfile.py | 21 ++++++++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/sbws/core/generate.py b/sbws/core/generate.py index f9b46cb..971ed9e 100644 --- a/sbws/core/generate.py +++ b/sbws/core/generate.py @@ -106,7 +106,7 @@ def main(args, conf): bw_file = V3BWFile.from_results(results, state_fpath, args.scale_constant, scaling_method, torflow_cap=args.torflow_bw_margin, - torflow_round_digs=args.torflow_round_digs, + round_digs=args.round_digs, secs_recent=args.secs_recent, secs_away=args.secs_away, min_num=args.min_num, diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py index a050744..d0e53f9 100644 --- a/sbws/lib/v3bwfile.py +++ b/sbws/lib/v3bwfile.py @@ -488,7 +488,7 @@ class V3BWFile(object): scaling_method=TORFLOW_SCALING, torflow_obs=TORFLOW_OBS_LAST, torflow_cap=TORFLOW_BW_MARGIN, - torflow_round_digs=PROP276_ROUND_DIG, + round_digs=PROP276_ROUND_DIG, secs_recent=None, secs_away=None, min_num=0, consensus_path=None, max_bw_diff_perc=MAX_BW_DIFF_PERC, reverse=False): @@ -533,7 +533,7 @@ class V3BWFile(object): # log.debug(bw_lines[-1]) elif scaling_method == TORFLOW_SCALING: bw_lines = cls.bw_torflow_scale(bw_lines_raw, torflow_obs, - torflow_cap, torflow_round_digs) + torflow_cap, round_digs) # log.debug(bw_lines[-1]) cls.update_progress( cls, bw_lines, header, number_consensus_relays, state) diff --git a/tests/unit/lib/test_v3bwfile.py b/tests/unit/lib/test_v3bwfile.py index f9c50d5..86b979b 100644 --- a/tests/unit/lib/test_v3bwfile.py +++ b/tests/unit/lib/test_v3bwfile.py @@ -6,7 +6,7 @@ import os.path
from sbws import __version__ as version from sbws.globals import (SPEC_VERSION, SBWS_SCALING, TORFLOW_SCALING, - MIN_REPORT) + MIN_REPORT, TORFLOW_ROUND_DIG, PROP276_ROUND_DIG) from sbws.lib.resultdump import Result, load_result_file, ResultSuccess from sbws.lib.v3bwfile import (V3BWHeader, V3BWLine, TERMINATOR, LINE_SEP, KEYVALUE_SEP_V1, num_results_of_type, @@ -266,14 +266,21 @@ def test_sbws_scale(datadir):
def test_torflow_scale(datadir): results = load_result_file(str(datadir.join("results.txt"))) - v3bwfile = V3BWFile.from_results(results, scaling_method=TORFLOW_SCALING) - assert v3bwfile.bw_lines[0].bw == 520 v3bwfile = V3BWFile.from_results(results, scaling_method=TORFLOW_SCALING, - torflow_cap=0.0001) - assert v3bwfile.bw_lines[0].bw == 520 + round_digs=TORFLOW_ROUND_DIG) + assert v3bwfile.bw_lines[0].bw == 524 + v3bwfile = V3BWFile.from_results(results, scaling_method=TORFLOW_SCALING, + torflow_cap=0.0001, + round_digs=TORFLOW_ROUND_DIG) + assert v3bwfile.bw_lines[0].bw == 524 v3bwfile = V3BWFile.from_results(results, scaling_method=TORFLOW_SCALING, - torflow_cap=1, torflow_round_digs=1) - assert v3bwfile.bw_lines[0].bw == 500 + torflow_cap=1, + round_digs=TORFLOW_ROUND_DIG) + assert v3bwfile.bw_lines[0].bw == 524 + v3bwfile = V3BWFile.from_results(results, scaling_method=TORFLOW_SCALING, + torflow_cap=1, + round_digs=PROP276_ROUND_DIG) + assert v3bwfile.bw_lines[0].bw == 520
def test_results_away_each_other(datadir):
tor-commits@lists.torproject.org