mirror of
https://github.com/gonum/gonum.git
synced 2025-10-06 07:37:03 +08:00
stat: allow tolerance in TestROC
This commit is contained in:
@@ -12,6 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestROC(t *testing.T) {
|
func TestROC(t *testing.T) {
|
||||||
|
const tol = 1e-14
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
y []float64
|
y []float64
|
||||||
c []bool
|
c []bool
|
||||||
@@ -211,10 +213,10 @@ func TestROC(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for i, test := range cases {
|
for i, test := range cases {
|
||||||
gotTPR, gotFPR, gotThresh := ROC(test.cutoffs, test.y, test.c, test.w)
|
gotTPR, gotFPR, gotThresh := ROC(test.cutoffs, test.y, test.c, test.w)
|
||||||
if !floats.Same(gotTPR, test.wantTPR) {
|
if !floats.Same(gotTPR, test.wantTPR) && !floats.EqualApprox(gotTPR, test.wantTPR, tol) {
|
||||||
t.Errorf("%d: unexpected TPR got:%v want:%v", i, gotTPR, test.wantTPR)
|
t.Errorf("%d: unexpected TPR got:%v want:%v", i, gotTPR, test.wantTPR)
|
||||||
}
|
}
|
||||||
if !floats.Same(gotFPR, test.wantFPR) {
|
if !floats.Same(gotFPR, test.wantFPR) && !floats.EqualApprox(gotFPR, test.wantFPR, tol) {
|
||||||
t.Errorf("%d: unexpected FPR got:%v want:%v", i, gotFPR, test.wantFPR)
|
t.Errorf("%d: unexpected FPR got:%v want:%v", i, gotFPR, test.wantFPR)
|
||||||
}
|
}
|
||||||
if !floats.Same(gotThresh, test.wantThresh) {
|
if !floats.Same(gotThresh, test.wantThresh) {
|
||||||
|
Reference in New Issue
Block a user