[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 06/09: util: futurize consensus/consensus-simulati
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 06/09: util: futurize consensus/consensus-simulation |
Date: |
Tue, 12 Feb 2019 12:10:30 +0100 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnunet.
commit cf521c41f72c380cc8fc50cbd0d8836e9ebe3252
Author: ng0 <address@hidden>
AuthorDate: Tue Feb 12 11:06:05 2019 +0000
util: futurize consensus/consensus-simulation
Signed-off-by: ng0 <address@hidden>
---
src/consensus/consensus-simulation.py.in | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/consensus/consensus-simulation.py.in
b/src/consensus/consensus-simulation.py.in
index 38e29230a..161015d00 100644
--- a/src/consensus/consensus-simulation.py.in
+++ b/src/consensus/consensus-simulation.py.in
@@ -19,6 +19,10 @@
from __future__ import absolute_import
from __future__ import print_function
+from __future__ import division
+from builtins import str
+from builtins import range
+from past.utils import old_div
import argparse
import random
from math import ceil, log, floor
@@ -39,18 +43,18 @@ def bsc(n):
def simulate(k, n, verbose):
assert k < n
- largest_arc = int(2**ceil(log(n, 2))) / 2
+ largest_arc = old_div(int(2**ceil(log(n, 2))), 2)
num_ghosts = (2 * largest_arc) - n
if verbose:
print("we have", num_ghosts, "ghost peers")
# n.b. all peers with idx<k are evil
- peers = range(n)
+ peers = list(range(n))
# py2-3 compatible, backwards.
# refer to http://python-future.org/compatible_idioms.html#xrange
- info = [1 << x for x in xrange(n)]
+ info = [1 << x for x in range(n)]
def done_p():
- for x in xrange(k, n):
+ for x in range(k, n):
if bsc(info[x]) < n-k:
return False
return True
@@ -63,7 +67,7 @@ def simulate(k, n, verbose):
if verbose:
print("-- subround --")
new_info = [x for x in info]
- for peer_physical in xrange(n):
+ for peer_physical in range(n):
peer_logical = peers[peer_physical]
peer_type = None
partner_logical = (peer_logical + arc) % n
@@ -105,6 +109,6 @@ if __name__ == "__main__":
args = parser.parse_args()
sum = 0.0
- for n in xrange(0, args.r):
+ for n in range(0, args.r):
sum += simulate(args.k, args.n, args.verbose)
- print(sum / args.r)
+ print(old_div(sum, args.r))
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] branch master updated (abf25faba -> c886489c9), gnunet, 2019/02/12
- [GNUnet-SVN] [gnunet] 02/09: util: futurize contrib/scripts/gnunet-chk, gnunet, 2019/02/12
- [GNUnet-SVN] [gnunet] 01/09: util: futurize gnunet-qr, gnunet, 2019/02/12
- [GNUnet-SVN] [gnunet] 04/09: util: futurize contrib/scripts/pydiffer, gnunet, 2019/02/12
- [GNUnet-SVN] [gnunet] 03/09: util: futurize contrib/scripts/gnunet_pyexpect, gnunet, 2019/02/12
- [GNUnet-SVN] [gnunet] 05/09: util: futurize contrib/scripts/terminate, gnunet, 2019/02/12
- [GNUnet-SVN] [gnunet] 07/09: util: futurize fs/test_gnunet_fs_psd, gnunet, 2019/02/12
- [GNUnet-SVN] [gnunet] 08/09: util: futurize revocation/test_local_revocation, gnunet, 2019/02/12
- [GNUnet-SVN] [gnunet] 09/09: Merge branch 'master' of gnunet.org:gnunet, gnunet, 2019/02/12
- [GNUnet-SVN] [gnunet] 06/09: util: futurize consensus/consensus-simulation,
gnunet <=