You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2011/10/04 16:52:32 UTC

svn commit: r1178819 - /lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/search/CheckHits.java

Author: rmuir
Date: Tue Oct  4 14:52:32 2011
New Revision: 1178819

URL: http://svn.apache.org/viewvc?rev=1178819&view=rev
Log:
LUCENE-3478: ensure the epsilon is always at least a tiny size for crazy small scores

Modified:
    lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/search/CheckHits.java

Modified: lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/search/CheckHits.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/search/CheckHits.java?rev=1178819&r1=1178818&r2=1178819&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/search/CheckHits.java (original)
+++ lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/search/CheckHits.java Tue Oct  4 14:52:32 2011
@@ -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);
   }
 
   /**