mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-11-10 21:32:43 +08:00
fix(test): fix always-true assertions in reranker normalize test (#22039)
This commit is contained in:
1 parent
50db7f5c7a
commit
7bf05bcb3c
1 file changed
+4
-3
@@ -62,9 +62,10 @@ func TestNormalizeRerankScores_InRange_Preserved(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
want := append([]float64(nil), tc.in...)
|
||||||
got := NormalizeRerankScores(tc.in)
|
got := NormalizeRerankScores(tc.in)
|
||||||
if !floatsClose(got, tc.in, 1e-9) {
|
if !floatsClose(got, want, 1e-9) {
|
||||||
t.Errorf("got %v, want %v (must be preserved)", got, tc.in)
|
t.Errorf("got %v, want %v (must be preserved)", got, want)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -75,8 +76,8 @@ func TestNormalizeRerankScores_InRange_Preserved(t *testing.T) {
|
|||||||
// on when sorting by rerank score.
|
// on when sorting by rerank score.
|
||||||
func TestNormalizeRerankScores_PreservesOrdering(t *testing.T) {
|
func TestNormalizeRerankScores_PreservesOrdering(t *testing.T) {
|
||||||
in := []float64{-5.0, 12.0, 3.0, -1.0}
|
in := []float64{-5.0, 12.0, 3.0, -1.0}
|
||||||
got := NormalizeRerankScores(in)
|
|
||||||
wantOrder := argsortDesc(in)
|
wantOrder := argsortDesc(in)
|
||||||
|
got := NormalizeRerankScores(in)
|
||||||
gotOrder := argsortDesc(got)
|
gotOrder := argsortDesc(got)
|
||||||
if !intsEqual(wantOrder, gotOrder) {
|
if !intsEqual(wantOrder, gotOrder) {
|
||||||
t.Errorf("ordering changed: want %v, got %v", wantOrder, gotOrder)
|
t.Errorf("ordering changed: want %v, got %v", wantOrder, gotOrder)
|
||||||
|
|||||||
Reference in new issue
Block a user