one more
parent
dbff6792fa
commit
1da2d9fe9c
|
|
@ -54,3 +54,7 @@ class BucketChooserProportionalLogRandom:
|
||||||
1 + int(100 * math.log2(i[1])),
|
1 + int(100 * math.log2(i[1])),
|
||||||
) for i in content
|
) for i in content
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class BucketChooserProportionalRandom(BucketChooserProportionalLogRandom):
|
||||||
|
def xform(self, content):
|
||||||
|
return [(i[0], 1+int(100*i[1])) for i in content]
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ class TestBucketChoosers(unittest.TestCase):
|
||||||
def test_choosers(self):
|
def test_choosers(self):
|
||||||
for chooser in [
|
for chooser in [
|
||||||
bucket.BucketChooserProportionalLogRandom(),
|
bucket.BucketChooserProportionalLogRandom(),
|
||||||
|
bucket.BucketChooserProportionalRandom(),
|
||||||
]:
|
]:
|
||||||
with self.assertRaises(AssertionError):
|
with self.assertRaises(AssertionError):
|
||||||
self.assertRaises(chooser.choose([]))
|
self.assertRaises(chooser.choose([]))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue