From eb96ac35f9c7eca4bf493d8b49388c2f86bbf6d6 Mon Sep 17 00:00:00 2001 From: Alex Klibisz <8015228+alexklibisz@users.noreply.github.com> Date: Sat, 23 Mar 2024 11:36:20 -0700 Subject: [PATCH] Add rounding --- .../klibisz/elastiknn/models/PermutationLshModelSuite.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/elastiknn-plugin/src/test/scala/com/klibisz/elastiknn/models/PermutationLshModelSuite.scala b/elastiknn-plugin/src/test/scala/com/klibisz/elastiknn/models/PermutationLshModelSuite.scala index 43a2f1fb1..c10fe6d2c 100644 --- a/elastiknn-plugin/src/test/scala/com/klibisz/elastiknn/models/PermutationLshModelSuite.scala +++ b/elastiknn-plugin/src/test/scala/com/klibisz/elastiknn/models/PermutationLshModelSuite.scala @@ -15,6 +15,10 @@ import scala.util.Random class PermutationLshModelSuite extends AnyFunSuite with Matchers with LuceneSupport { + // For some unknown reason the exact score values started to slightly differ around March 2024. + def round(f: Float): Float = + BigDecimal(f).setScale(6, BigDecimal.RoundingMode.HALF_UP).floatValue + test("lucene example where counting matters") { // This example demonstrates a tricky condition: 0 appears once in the query vector and three times in corpus vector @@ -62,7 +66,7 @@ class PermutationLshModelSuite extends AnyFunSuite with Matchers with LuceneSupp } { case (r, s) => queryVecs.map { v => val q = new HashingQuery("vec", v, 200, lsh.hash(v.values), cosine) - s.search(q.toLuceneQuery(r), 100).scoreDocs.map(sd => (sd.doc, sd.score)).toVector + s.search(q.toLuceneQuery(r), 100).scoreDocs.map(sd => (sd.doc, round(sd.score))).toVector } } queryResults