Skip to content

Commit

Permalink
use require.InEpsilonf
Browse files Browse the repository at this point in the history
  • Loading branch information
feitian124 committed Oct 5, 2021
1 parent 3995d76 commit 96bf2ea
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions statistics/sample_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,8 @@ func SubTestWeightedSampling() func(*testing.T) {
require.Nil(t, rs.Close())
}
expFrequency := float64(sampleNum) * float64(loopCnt) / float64(rowNum)
delta := 0.5
for _, cnt := range itemCnt {
if float64(cnt) < expFrequency/(1+delta) || float64(cnt) > expFrequency*(1+delta) {
require.Truef(t, false, "The frequency %v is exceed the Chernoff Bound", cnt)
}
require.InEpsilonf(t, expFrequency, float64(cnt), 0.5, "The frequency %v is exceed the Chernoff Bound", cnt)
}
}
}
Expand Down Expand Up @@ -139,11 +136,8 @@ func SubTestDistributedWeightedSampling() func(*testing.T) {
}
}
expFrequency := float64(sampleNum) * float64(loopCnt) / float64(rowNum)
delta := 0.5
for _, cnt := range itemCnt {
if float64(cnt) < expFrequency/(1+delta) || float64(cnt) > expFrequency*(1+delta) {
require.Truef(t, false, "the frequency %v is exceed the Chernoff Bound", cnt)
}
require.InEpsilonf(t, expFrequency, float64(cnt), 0.5, "The frequency %v is exceed the Chernoff Bound", cnt)
}
}
}
Expand Down

0 comments on commit 96bf2ea

Please sign in to comment.