LUCENE-3478: ensure the epsilon is always at least a tiny size for crazy small scores

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1178819 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-10-04 14:52:32 +00:00
parent c1be69731d
commit 76fd471b54
1 changed files with 9 additions and 1 deletions

View File

@ -38,6 +38,14 @@ public class CheckHits {
*/
public static float EXPLAIN_SCORE_TOLERANCE_DELTA = 0.001f;
/**
* In general we use a relative epsilon, but some tests do crazy things
* like boost documents with 0, creating tiny tiny scores where the
* relative difference is large but the absolute difference is tiny.
* we ensure the the epsilon is always at least this big.
*/
public static float EXPLAIN_SCORE_TOLERANCE_MINIMUM = 1e-6f;
/**
* Tests that all documents up to maxDoc which are *not* in the
* expected result set, have an explanation which indicates that
@ -306,7 +314,7 @@ public class CheckHits {
}
private static float explainToleranceDelta(float f1, float f2) {
return Math.max(Math.abs(f1), Math.abs(f2)) * EXPLAIN_SCORE_TOLERANCE_DELTA;
return Math.max(EXPLAIN_SCORE_TOLERANCE_MINIMUM, Math.max(Math.abs(f1), Math.abs(f2)) * EXPLAIN_SCORE_TOLERANCE_DELTA);
}
/**