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)
Esempio n. 2
0
 def test_should_succeed_for_delta_metrics_with_the_distribution_type(self):
     test_distribution = distribution.create_explicit([0.1, 0.3, 0.5])
     distribution.add_sample(0.4, test_distribution)
     v = metric_value.create(labels=self.TEST_LABELS,
                             distributionValue=test_distribution)
     want = 2 * test_distribution.count
     got = metric_value.merge(MetricKind.DELTA, v, v)
     expect(got.distributionValue.count).to(equal(want))
 def test_should_succeed_for_delta_metrics_with_the_distribution_type(self):
     test_distribution = distribution.create_explicit([0.1, 0.3, 0.5])
     distribution.add_sample(0.4, test_distribution)
     v = metric_value.create(labels=self.TEST_LABELS,
                             distributionValue=test_distribution)
     want = 2 * test_distribution.count
     got = metric_value.merge(MetricKind.DELTA, v, v)
     expect(got.distributionValue.count).to(equal(want))
 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)
def _make_explicit_dist():
    return distribution.create_explicit([0.1, 0.3, 0.5, 0.7])
 def test_should_succeed_if_input_bounds_are_unsorted(self):
     want = [0.1, 0.2, 0.3]
     got = distribution.create_explicit([0.3, 0.1, 0.2])
     expect(got.explicitBuckets.bounds).to(equal(want))
 def test_should_succeed_if_inputs_are_ok(self):
     want = [0.1, 0.2, 0.3]
     got = distribution.create_explicit([0.1, 0.2, 0.3])
     expect(got.explicitBuckets.bounds).to(equal(want))
     expect(len(got.bucketCounts)).to(equal(len(want) + 1))
 def test_should_fail_if_there_are_matching_bounds(self):
     testf = lambda: distribution.create_explicit([0.0, 0.1, 0.1])
     expect(testf).to(raise_error(ValueError))
def _make_explicit_dist():
    return distribution.create_explicit([0.1, 0.3, 0.5, 0.7])
 def test_should_succeed_if_input_bounds_are_unsorted(self):
     want = [0.1, 0.2, 0.3]
     got = distribution.create_explicit([0.3, 0.1, 0.2])
     expect(got.explicitBuckets.bounds).to(equal(want))
 def test_should_succeed_if_inputs_are_ok(self):
     want = [0.1, 0.2, 0.3]
     got = distribution.create_explicit([0.1, 0.2, 0.3])
     expect(got.explicitBuckets.bounds).to(equal(want))
     expect(len(got.bucketCounts)).to(equal(len(want) + 1))
 def test_should_fail_if_there_are_matching_bounds(self):
     testf = lambda: distribution.create_explicit([0.0, 0.1, 0.1])
     expect(testf).to(raise_error(ValueError))