Skip to content

Commit bf9af17

Browse files
authored
Compare floats with allowable delta diff in VectorScorerFactoryTests (#126271)
As we do in similar tests elsewhere, this commit updates the comparison assertion of float scores with an allowable delta difference, in order to tolerate small rounding differences which may result from the order of accumulations.
1 parent f77a617 commit bf9af17

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libs/simdvec/src/test/java/org/elasticsearch/simdvec/VectorScorerFactoryTests.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
// @com.carrotsearch.randomizedtesting.annotations.Repeat(iterations = 100)
5151
public class VectorScorerFactoryTests extends AbstractVectorTestCase {
5252

53+
private static final float DELTA = 1e-4f;
54+
5355
// bounds of the range of values that can be seen by int7 scalar quantized vectors
5456
static final byte MIN_INT7_VALUE = 0;
5557
static final byte MAX_INT7_VALUE = 127;
@@ -278,7 +280,7 @@ void testRandomScorerImpl(long maxChunkSize, Function<Integer, float[]> floatArr
278280

279281
var expected = luceneScore(sim, qVectors[idx0], qVectors[idx1], correction, corrections[idx0], corrections[idx1]);
280282
var scorer = factory.getInt7SQVectorScorer(VectorSimilarityType.of(sim), values, vectors[idx0]).get();
281-
assertThat(scorer.score(idx1), equalTo(expected));
283+
assertEquals(scorer.score(idx1), expected, DELTA);
282284
}
283285
}
284286
}

0 commit comments

Comments
 (0)