ashvardanian / SimSIMD

Up to 200x Faster Dot Products & Similarity Metrics — for Python, Rust, C, JS, and Swift, supporting f64, f32, f16 real & complex, i8, and bit vectors using SIMD for both AVX2, AVX-512, NEON, SVE, & SVE2 📐
https://ashvardanian.com/posts/simsimd-faster-scipy/
Apache License 2.0
988 stars 59 forks source link

Bug: The One-to-One Distance Python example compares an array value with a scalar value #219

Closed yurivict closed 3 weeks ago

yurivict commented 3 weeks ago

Describe the bug

This example from README:

from random import randint
import numpy as np
import simsimd as simd

length1, length2 = randint(1, 100), randint(1, 100)
vec1 = np.random.randint(0, 1000, length1).astype(np.uint16)
vec2 = np.random.randint(0, 1000, length2).astype(np.uint16)

slow_result = np.intersect1d(vec1, vec2)
fast_result = simd.intersect(vec1, vec2)
assert slow_result == fast_result

compares these 2 values:

slow_result=[299 926]
fast_result=0.0

Steps to reproduce

n/a

Expected behavior

n/a

SimSIMD version

5.9.6

Operating System

FreeBSD 14.1

Hardware architecture

x86

Which interface are you using?

Python bindings

Contact Details

No response

Are you open to being tagged as a contributor?

Is there an existing issue for this?

Code of Conduct

ashvardanian commented 3 weeks ago

You are right, the length of the NumPy result should be taken. Will patch soon. Thanks!