Relax noise margin in TestOneWeightedHistogram

Signed-off-by: Mike Spreitzer <mspreitz@us.ibm.com>
This commit is contained in:
Mike Spreitzer 2024-07-24 17:39:33 -04:00
parent 696ad19801
commit 77541c1e35
No known key found for this signature in database
GPG Key ID: 4683587BD4E203FA

View File

@ -99,7 +99,7 @@ func exerciseWeightedHistograms(t *testing.T, whSpecs ...weightedHistogramSpecFu
for _, term := range terms {
ee.sum += term
}
t.Logf("Adding expectation %#+v", ee)
t.Logf("At idx=%v, adding expectation of buckets=%#+v, upperBounds=%#+v, sum=%v, count=%v", whIdx, ee.buckets, ee.upperBounds, ee.sum, ee.count)
expectations = append(expectations, ee)
}
// Do the planned calls on ObserveWithWeight, in randomized order
@ -142,8 +142,10 @@ func exerciseWeightedHistograms(t *testing.T, whSpecs ...weightedHistogramSpecFu
actualSum := actualHist.GetSampleSum()
num := math.Abs(actualSum - ee.sum)
den := math.Max(math.Abs(actualSum), math.Abs(ee.sum))
if num > den/1e14 {
t.Errorf("At idx=%d, expected sum %v but got %v, err=%v", idx, ee.sum, actualSum, actualSum-ee.sum)
relErr := num / den
// Issue 120112 reports relative errors as high as 9.55994394104272e-14
if relErr > 1e-13 {
t.Errorf("At idx=%d, expected sum %v but got %v, err=%v, relativeErr=%v", idx, ee.sum, actualSum, actualSum-ee.sum, relErr)
}
}
}