Skip to content

Commit 1909516

Browse files
committed
fixed tests and logic
Signed-off-by: amanycodes <amanycodes@gmail.com>
1 parent 3bdff22 commit 1909516

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

promql/functions.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,12 +1351,12 @@ func histogramVariance(vals []parser.Value, enh *EvalNodeHelper, varianceToResul
13511351
continue
13521352
}
13531353
var val float64
1354-
if bucket.Lower <= 0 && bucket.Upper >= 0 {
1355-
val = 0
1354+
if sample.H.UsesCustomBuckets() {
1355+
// use arithmetic mean in case of NHCB.
1356+
val = (bucket.Upper * bucket.Lower) / 2.0
13561357
} else {
1357-
if sample.H.UsesCustomBuckets() {
1358-
// use arithmetic mean in case of NHCB.
1359-
val = (bucket.Upper * bucket.Lower) / 2.0
1358+
if bucket.Lower <= 0 && bucket.Upper >= 0 {
1359+
val = 0
13601360
} else {
13611361
val = math.Sqrt(bucket.Upper * bucket.Lower)
13621362
if bucket.Upper < 0 {

promql/promqltest/testdata/histograms.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ eval instant at 50m histogram_avg(testhistogram3)
9595

9696
# Test histogram_stddev. This has no classic equivalent.
9797
eval instant at 50m histogram_stddev(testhistogram3)
98-
{start="positive"} 2.768081055040247
99-
{start="negative"} 4.187667907081458
98+
{start="positive"} 2.962188994031886
99+
{start="negative"} 3.9825070621406313
100100

101101
# Test histogram_stdvar. This has no classic equivalent.
102102
eval instant at 50m histogram_stdvar(testhistogram3)
103-
{start="positive"} 7.662272727272727
104-
{start="negative"} 17.536562500000002
103+
{start="positive"} 8.774563636363636
104+
{start="negative"} 15.860362500000003
105105

106106
# Test histogram_fraction.
107107

0 commit comments

Comments
 (0)