コード例 #1
0
 def setUp(self):
     self.merge_triples = ((
         distribution.create_exponential(3, 2, 0.1),
         distribution.create_exponential(3, 2, 0.1),
         distribution.create_exponential(4, 2, 0.1),
     ), (distribution.create_linear(3, 0.2, 0.1),
         distribution.create_linear(3, 0.2, 0.1),
         distribution.create_linear(4, 0.2, 0.1)), (
             distribution.create_explicit([0.1, 0.3]),
             distribution.create_explicit([0.1, 0.3]),
             distribution.create_explicit([0.1, 0.3, 0.5]),
         ))
     for d1, d2, _ in self.merge_triples:
         distribution.add_sample(_LOW_SAMPLE, d1)
         distribution.add_sample(_HIGH_SAMPLE, d2)
コード例 #2
0
 def setUp(self):
     self.merge_triples = (
         (
             distribution.create_exponential(3, 2, 0.1),
             distribution.create_exponential(3, 2, 0.1),
             distribution.create_exponential(4, 2, 0.1),
         ),(
             distribution.create_linear(3, 0.2, 0.1),
             distribution.create_linear(3, 0.2, 0.1),
             distribution.create_linear(4, 0.2, 0.1)
         ),(
             distribution.create_explicit([0.1, 0.3]),
             distribution.create_explicit([0.1, 0.3]),
             distribution.create_explicit([0.1, 0.3, 0.5]),
         )
     )
     for d1, d2, _ in self.merge_triples:
         distribution.add_sample(_LOW_SAMPLE, d1)
         distribution.add_sample(_HIGH_SAMPLE, d2)
コード例 #3
0
def _make_exponential_dist():
    return distribution.create_exponential(3, 2, 0.1)
コード例 #4
0
 def test_should_succeed_if_inputs_are_ok(self):
     num_finite_buckets = 1
     got = distribution.create_exponential(num_finite_buckets, 1.1, 0.1)
     expect(len(got.bucketCounts)).to(equal(num_finite_buckets + 2))
コード例 #5
0
 def test_should_fail_if_scale_is_bad(self):
     testf = lambda: distribution.create_exponential(1, 1.1, -0.1)
     expect(testf).to(raise_error(ValueError))
コード例 #6
0
 def test_should_fail_if_growth_factor_is_bad(self):
     testf = lambda: distribution.create_exponential(1, 0.9, 0.1)
     expect(testf).to(raise_error(ValueError))
コード例 #7
0
 def test_should_fail_if_num_finite_buckets_is_bad(self):
     testf = lambda: distribution.create_exponential(0, 1.1, 0.1)
     expect(testf).to(raise_error(ValueError))
コード例 #8
0
def _wanted_distribution_with_sample(value, *args):
    d = distribution.create_exponential(*args)
    distribution.add_sample(value, d)
    return d
コード例 #9
0
def _wanted_distribution_with_sample(value, *args):
    d = distribution.create_exponential(*args)
    distribution.add_sample(value, d)
    return d
コード例 #10
0
def _make_exponential_dist():
    return distribution.create_exponential(3, 2, 0.1)
コード例 #11
0
 def test_should_succeed_if_inputs_are_ok(self):
     num_finite_buckets = 1
     got = distribution.create_exponential(num_finite_buckets, 1.1, 0.1)
     expect(len(got.bucketCounts)).to(equal(num_finite_buckets + 2))
コード例 #12
0
 def test_should_fail_if_scale_is_bad(self):
     testf = lambda: distribution.create_exponential(1, 1.1, -0.1)
     expect(testf).to(raise_error(ValueError))
コード例 #13
0
 def test_should_fail_if_growth_factor_is_bad(self):
     testf = lambda: distribution.create_exponential(1, 0.9, 0.1)
     expect(testf).to(raise_error(ValueError))
コード例 #14
0
 def test_should_fail_if_num_finite_buckets_is_bad(self):
     testf = lambda: distribution.create_exponential(0, 1.1, 0.1)
     expect(testf).to(raise_error(ValueError))