Skip to content

Commit

Permalink
Fix: mixed-precision tolerance in JS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Mar 5, 2024
1 parent c694880 commit b72f658
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion javascript/usearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ test("Expected results", () => {

assert.equal(index.size(), 1);
assert.deepEqual(results.keys, new BigUint64Array([42n]));
assert.deepEqual(results.distances, new Float32Array([0]));

// When using mixed-precision, we can't expect the resulting value
// to be exactly 0, but it should be very close to it.
var actual = Number(results.distances[0]);
var expected = 0; // The expected value
var difference = Math.abs(actual - expected);
assert.ok(difference < 0.01);
});


Expand Down

0 comments on commit b72f658

Please sign in to comment.