@@ -311,10 +311,10 @@ def test_vsim_unexisting(d_client):
311
311
312
312
@skip_if_server_version_lt ("7.9.0" )
313
313
def test_vsim_with_filter (d_client ):
314
- elements_count = 30
314
+ elements_count = 50
315
315
vector_dim = 800
316
316
for i in range (elements_count ):
317
- float_array = [random .uniform (0 , 10 ) for x in range (vector_dim )]
317
+ float_array = [random .uniform (10 , 20 ) for x in range (vector_dim )]
318
318
attributes = {"index" : i , "elem_name" : f"elem_{ i } " }
319
319
d_client .vset ().vadd (
320
320
"myset" ,
@@ -323,6 +323,15 @@ def test_vsim_with_filter(d_client):
323
323
numlinks = 4 ,
324
324
attributes = attributes ,
325
325
)
326
+ float_array = [- random .uniform (10 , 20 ) for x in range (vector_dim )]
327
+ attributes = {"index" : elements_count , "elem_name" : "elem_special" }
328
+ d_client .vset ().vadd (
329
+ "myset" ,
330
+ float_array ,
331
+ "elem_special" ,
332
+ numlinks = 4 ,
333
+ attributes = attributes ,
334
+ )
326
335
sim = d_client .vset ().vsim ("myset" , input = "elem_1" , filter = ".index > 10" )
327
336
assert len (sim ) == 10
328
337
assert isinstance (sim , list )
@@ -350,17 +359,19 @@ def test_vsim_with_filter(d_client):
350
359
sim = d_client .vset ().vsim (
351
360
"myset" ,
352
361
input = "elem_1" ,
353
- filter = ".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_29 ']" ,
362
+ filter = ".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_special ']" ,
354
363
filter_ef = 1 ,
355
364
)
356
- assert len (sim ) == 0
365
+ assert len (sim ) == 0 , (
366
+ f"Expected 0 results, but got { len (sim )} with filter_ef=1, sim: { sim } "
367
+ )
357
368
assert isinstance (sim , list )
358
369
359
370
sim = d_client .vset ().vsim (
360
371
"myset" ,
361
372
input = "elem_1" ,
362
- filter = ".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_29 ']" ,
363
- filter_ef = 20 ,
373
+ filter = ".index > 28 and .elem_name in ['elem_12', 'elem_17', 'elem_special ']" ,
374
+ filter_ef = 500 ,
364
375
)
365
376
assert len (sim ) == 1
366
377
assert isinstance (sim , list )
@@ -369,7 +380,7 @@ def test_vsim_with_filter(d_client):
369
380
@skip_if_server_version_lt ("7.9.0" )
370
381
def test_vsim_truth_no_thread_enabled (d_client ):
371
382
elements_count = 5000
372
- vector_dim = 30
383
+ vector_dim = 50
373
384
for i in range (1 , elements_count + 1 ):
374
385
float_array = [random .uniform (10 * i , 1000 * i ) for x in range (vector_dim )]
375
386
d_client .vset ().vadd ("myset" , float_array , f"elem_{ i } " )
@@ -396,7 +407,7 @@ def test_vsim_truth_no_thread_enabled(d_client):
396
407
)
397
408
398
409
found_better_match = False
399
- for index , ( score_with_truth , score_without_truth ) in enumerate ( results_scores ) :
410
+ for score_with_truth , score_without_truth in results_scores :
400
411
if score_with_truth < score_without_truth :
401
412
assert False , (
402
413
"Score with truth [{score_with_truth}] < score without truth [{score_without_truth}]"
@@ -764,15 +775,15 @@ def test_vset_commands_without_decoding_responces(client):
764
775
# test vadd
765
776
elements = ["elem1" , "elem2" , "elem3" ]
766
777
for elem in elements :
767
- float_array = [random .uniform (0 , 10 ) for x in range (0 , 8 )]
778
+ float_array = [random .uniform (0.5 , 10 ) for x in range (0 , 8 )]
768
779
resp = client .vset ().vadd ("myset" , float_array , element = elem )
769
780
assert resp == 1
770
781
771
782
# test vemb
772
783
emb = client .vset ().vemb ("myset" , "elem1" )
773
784
assert len (emb ) == 8
774
785
assert isinstance (emb , list )
775
- assert all (isinstance (x , float ) for x in emb )
786
+ assert all (isinstance (x , float ) for x in emb ), f"Expected float values, got { emb } "
776
787
777
788
emb_raw = client .vset ().vemb ("myset" , "elem1" , raw = True )
778
789
assert emb_raw ["quantization" ] == b"int8"
0 commit comments