mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 05:28:04 +00:00
Port to Python 3.
This commit is contained in:
parent
8d84be77d8
commit
2ca223a67c
@ -31,6 +31,7 @@ PORTED_MODULES = [
|
||||
"allmydata.util.pollmixin",
|
||||
"allmydata.util._python3",
|
||||
"allmydata.util.spans",
|
||||
"allmydata.util.statistics",
|
||||
"allmydata.util.time_format",
|
||||
"allmydata.test.common_py3",
|
||||
]
|
||||
|
@ -1,3 +1,8 @@
|
||||
"""
|
||||
Statistical utilities.
|
||||
|
||||
Ported to Python 3.
|
||||
"""
|
||||
# Copyright (c) 2009 Shawn Willden
|
||||
# mailto:shawn@willden.org
|
||||
# I hereby license all patches I have contributed or will contribute to the
|
||||
@ -5,7 +10,18 @@
|
||||
# either the GNU General Public License, version 2 or later, or under the
|
||||
# Transitive Grace Period Public License, version 1 or later.
|
||||
|
||||
from __future__ import division, print_function
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, int, list, object, range, str, max, min # noqa: F401
|
||||
|
||||
from functools import reduce
|
||||
|
||||
from allmydata.util.mathutil import round_sigfigs
|
||||
import math
|
||||
import sys
|
||||
@ -78,7 +94,7 @@ def survival_pmf_via_bd(p_list):
|
||||
"""
|
||||
pmf_list = [ binomial_distribution_pmf(p_list.count(p), p)
|
||||
for p in set(p_list) ]
|
||||
return reduce(convolve, pmf_list)
|
||||
return list(reduce(convolve, pmf_list))
|
||||
|
||||
def survival_pmf_via_conv(p_list):
|
||||
"""
|
||||
@ -89,7 +105,7 @@ def survival_pmf_via_conv(p_list):
|
||||
intended for internal use and testing only.
|
||||
"""
|
||||
pmf_list = [ [1 - p, p] for p in p_list ];
|
||||
return reduce(convolve, pmf_list)
|
||||
return list(reduce(convolve, pmf_list))
|
||||
|
||||
def print_pmf(pmf, n=4, out=sys.stdout):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user