Apache Solr open-source search software
LUCENE-3478: ensure the epsilon is always at least a tiny size for crazy small scores
Robert Muir76fd471b54ab
diff --git a/lucene/src/test-framework/org/apache/lucene/search/CheckHits.java b/lucene/src/test-framework/org/apache/lucene/search/CheckHits.javaindex dbf6efa910d..3aab5faf06e 100644--- a/lucene/src/test-framework/org/apache/lucene/search/CheckHits.java+++ b/lucene/src/test-framework/org/apache/lucene/search/CheckHits.java@@ -37,6 +37,14 @@ public class CheckHits {* this allows for a small amount of relative variation*/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@@ -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);}/**