[tor-commits] [ooni-probe/master] Round up the inputunit length and do not add one.
art at torproject.org
art at torproject.org
Tue Jan 8 16:57:39 UTC 2013
commit 3e75dd2d2de197ed4f6f7565e3e3a5bd1add63e5
Author: aagbsn <aagbsn at extc.org>
Date: Sat Dec 29 17:31:54 2012 +0000
Round up the inputunit length and do not add one.
For cases where the input length is exactly divisible by the
inputunit size, the +1 is incorrect.
---
ooni/inputunit.py | 3 ++-
ooni/runner.py | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/ooni/inputunit.py b/ooni/inputunit.py
index 2ef89d8..2e80940 100644
--- a/ooni/inputunit.py
+++ b/ooni/inputunit.py
@@ -8,6 +8,7 @@
#
# :authors: Arturo Filastò
# :license: see included LICENSE file
+from math import ceil
class InputUnitFactory(object):
"""
@@ -37,7 +38,7 @@ class InputUnitFactory(object):
Returns the number of input units in the input unit factory.
"""
if not self.length:
- self.length = sum(1 for _ in self._inputs)/self.inputUnitSize
+ self.length = ceil(sum(1 for _ in self._inputs)/self.inputUnitSize)
return self.length
def next(self):
diff --git a/ooni/runner.py b/ooni/runner.py
index be8c968..b9deedc 100644
--- a/ooni/runner.py
+++ b/ooni/runner.py
@@ -379,7 +379,7 @@ def updateProgressMeters(test_filename, input_unit_factory,
config.state[test_filename].per_item_average = 2.0
input_unit_idx = float(config.stateDict[test_filename])
- input_unit_items = float(len(input_unit_factory) + 1)
+ input_unit_items = len(input_unit_factory)
test_case_number = float(test_case_number)
total_iterations = input_unit_items * test_case_number
current_iteration = input_unit_idx * test_case_number
More information about the tor-commits
mailing list