Skip to content

Commit

Permalink
Improve: Cleaner JS test
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Nov 18, 2024
1 parent b126ca8 commit 4a6d5c3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 0 additions & 6 deletions scripts/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,4 @@ test("Jensen-Shannon C vs JS", () => {
const result = simsimd.jensenshannon(f32sDistribution, f32sDistribution2);
const resultjs = fallback.jensenshannon(f32sDistribution, f32sDistribution2);
assertAlmostEqual(result, resultjs, 0.01);

const orthogonalVec1 = new Float32Array([1.0, 0.0, 0.0]);
const orthogonalVec2 = new Float32Array([0.0, 1.0, 0.0]);
const orthoResult = simsimd.jensenshannon(orthogonalVec1, orthogonalVec2);
const orthoResultJs = fallback.jensenshannon(orthogonalVec1, orthogonalVec2);
assertAlmostEqual(orthoResult, orthoResultJs, 0.01);
});
3 changes: 2 additions & 1 deletion scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,11 @@ def test_dense_bits(ndim, metric, capability, stats_fixture):
@pytest.mark.parametrize("capability", possible_capabilities)
def test_jensen_shannon(ndim, dtype, capability, stats_fixture):
"""Compares the simd.jensenshannon() function with scipy.spatial.distance.jensenshannon(), measuring the accuracy error for f16, and f32 types."""

np.random.seed()
if dtype == "float16" and is_running_under_qemu():
pytest.skip("Testing low-precision math isn't reliable in QEMU")

np.random.seed()
a = np.abs(np.random.randn(ndim)).astype(dtype)
b = np.abs(np.random.randn(ndim)).astype(dtype)
a /= np.sum(a)
Expand Down

0 comments on commit 4a6d5c3

Please sign in to comment.