зеркало из https://github.com/mozilla/taar.git
fix checking whether client id is in experiment (#181)
This commit is contained in:
Родитель
c688525b35
Коммит
f5693b7177
|
@ -15,7 +15,7 @@ def in_experiment(client_id, xp_prob=0.5):
|
|||
"""
|
||||
hex_client = "".join([c for c in client_id.lower() if c in "abcdef0123456789"])
|
||||
int_client = int(hex_client, 16)
|
||||
return int((int_client % 100) <= (xp_prob * 100))
|
||||
return int((int_client % 100) < (xp_prob * 100))
|
||||
|
||||
|
||||
def reorder_guids(guid_weight_tuples, size=None):
|
||||
|
|
|
@ -59,3 +59,10 @@ def test_experimental_branch_guid():
|
|||
|
||||
total = sum([in_experiment(id, cutoff - 0.1) for i in range(100)])
|
||||
assert total == 0
|
||||
|
||||
|
||||
def test_in_experiment_zero_prob():
|
||||
"""
|
||||
Test the edge case when some client IDs go to experiment even with 0 probability.
|
||||
"""
|
||||
assert not in_experiment('0ace1ca2a3519332ab93e76a049fe74091fa8fc9063399caa8545dd23f93de5c', xp_prob=0.0)
|
||||
|
|
Загрузка…
Ссылка в новой задаче