def expect_adds_test_samples_ok(self, make_dist_func):
     for t in _TEST_SAMPLES_AND_BUCKETS:
         d = make_dist_func()
         samples = t[u'samples']
         for s in samples:
             distribution.add_sample(s, d)
         expect(d.bucketCounts).to(equal(t[u'want']))
         _expect_stats_eq_direct_calc_from_samples(d, samples)
 def expect_adds_test_samples_ok(self, make_dist_func):
     for t in _TEST_SAMPLES_AND_BUCKETS:
         d = make_dist_func()
         samples = t[u'samples']
         for s in samples:
             distribution.add_sample(s, d)
         expect(d.bucketCounts).to(equal(t[u'want']))
         _expect_stats_eq_direct_calc_from_samples(d, samples)
Exemple #3
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 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 test_should_fail_if_no_buckets_are_set(self):
     testf = lambda: distribution.add_sample(_UNDERFLOW_SAMPLE,
                                             self.NOTHING_SET)
     expect(testf).to(raise_error(ValueError))
Exemple #8
0
def _wanted_distribution_with_sample(value, *args):
    d = distribution.create_exponential(*args)
    distribution.add_sample(value, d)
    return d
def _wanted_distribution_with_sample(value, *args):
    d = distribution.create_exponential(*args)
    distribution.add_sample(value, d)
    return d
 def test_should_fail_if_no_buckets_are_set(self):
     testf = lambda: distribution.add_sample(_UNDERFLOW_SAMPLE, self.
                                             NOTHING_SET)
     expect(testf).to(raise_error(ValueError))