File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 4
4
package datum_test
5
5
6
6
import (
7
+ "math"
7
8
"testing"
8
9
"testing/quick"
9
10
"time"
@@ -36,4 +37,8 @@ func TestMakeBucket(t *testing.T) {
36
37
if r := datum .GetBucketsCount (b ); r != 1 {
37
38
t .Errorf ("count not 1, got %v" , r )
38
39
}
40
+ bs := datum .GetBucketsByMax (b )
41
+ if r := datum .GetBucketsCount (b ); r != bs [math .Inf (+ 1 )] {
42
+ t .Errorf ("Inf bucket des not equal total observation count: %v vs %v" , r , bs [math .Inf (+ 1 )])
43
+ }
39
44
}
Original file line number Diff line number Diff line change @@ -262,13 +262,16 @@ func GetBucketsSum(d Datum) float64 {
262
262
}
263
263
}
264
264
265
- // GetBucketsByMax returns a map of bucket observations by their upper bonds, or panics if d is not a BucketsDatum
265
+ // GetBucketsByMax returns a map of cumulative bucket observations by their
266
+ // upper bonds, or panics if d is not a BucketsDatum.
266
267
func GetBucketsByMax (d Datum ) map [float64 ]uint64 {
267
268
switch d := d .(type ) {
268
269
case * BucketsDatum :
269
270
buckets := make (map [float64 ]uint64 )
271
+ cum := uint64 (0 )
270
272
for r , c := range d .Buckets () {
271
- buckets [r .Max ] = c
273
+ cum += c
274
+ buckets [r .Max ] = cum
272
275
}
273
276
return buckets
274
277
default :
You can’t perform that action at this time.
0 commit comments