Skip to content

Commit 2ad1099

Browse files
authored
test: make random determenistic in test_multidim_knn python test (#5335)
* fix: deterministic random for knn test * fix: review comments
1 parent f32d18e commit 2ad1099

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/dragonfly/search_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ async def test_multidim_knn(async_client: aioredis.Redis, index_type, algo_type)
297297
definition=IndexDefinition(index_type=index_type),
298298
)
299299

300+
# Use fixed seed for deterministic results
301+
np.random.seed(42)
302+
300303
def rand_point():
301304
return np.random.uniform(0, 10, NUM_DIMS).astype(np.float32)
302305

@@ -315,7 +318,9 @@ def rand_point():
315318
# Run 10 random queries
316319
for _ in range(10):
317320
center = rand_point()
318-
limit = random.randint(1, NUM_POINTS // 10)
321+
limit = np.random.randint(
322+
1, NUM_POINTS // 10 + 1
323+
) # +1 because numpy's randint is exclusive
319324

320325
expected_ids = [
321326
f"k{i}"

0 commit comments

Comments
 (0)