test_counter.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:privcount 作者: privcount 项目源码 文件源码
def try_counters(counters, modulus, N, X=None, multi_bin=True):
    '''
    Validate that a counter run with counters, modulus, N, X, and multi_bin works,
    and produces consistent results
    Also try a randomly selected number modulus_random between modulus_min and modulus,
    and a randomly selected number N_random between 0 and min(q_random, N)
    and a randomly selected number X_random between 0 and min(q_random, X)
    If X is None, use the 2-argument form of increment, otherwise, use the
    3-argument form
    '''
    # randrange is not uniformly distributed in python versions < 3.2
    modulus_random = SystemRandom().randrange(modulus_min, modulus)
    N_random = SystemRandom().randrange(0, min(modulus_random, N))
    X_random = None
    if X is not None:
        X_random = SystemRandom().randrange(0, min(modulus_random, X))
    run_counters(counters, modulus_random, N_random, X_random, multi_bin)
    run_counters(counters, modulus, N, X, multi_bin)

# Check the counter table is valid, and perform internal checks
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号