@@ -311,10 +311,10 @@ def test_vsim_unexisting(d_client):
311311
312312@skip_if_server_version_lt ("7.9.0" )
313313def test_vsim_with_filter (d_client ):
314- elements_count = 30
314+ elements_count = 50
315315 vector_dim = 800
316316 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 )]
318318 attributes = {"index" : i , "elem_name" : f"elem_{ i } " }
319319 d_client .vset ().vadd (
320320 "myset" ,
@@ -323,6 +323,15 @@ def test_vsim_with_filter(d_client):
323323 numlinks = 4 ,
324324 attributes = attributes ,
325325 )
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+ )
326335 sim = d_client .vset ().vsim ("myset" , input = "elem_1" , filter = ".index > 10" )
327336 assert len (sim ) == 10
328337 assert isinstance (sim , list )
@@ -350,17 +359,19 @@ def test_vsim_with_filter(d_client):
350359 sim = d_client .vset ().vsim (
351360 "myset" ,
352361 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 ']" ,
354363 filter_ef = 1 ,
355364 )
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+ )
357368 assert isinstance (sim , list )
358369
359370 sim = d_client .vset ().vsim (
360371 "myset" ,
361372 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 ,
364375 )
365376 assert len (sim ) == 1
366377 assert isinstance (sim , list )
@@ -369,7 +380,7 @@ def test_vsim_with_filter(d_client):
369380@skip_if_server_version_lt ("7.9.0" )
370381def test_vsim_truth_no_thread_enabled (d_client ):
371382 elements_count = 5000
372- vector_dim = 30
383+ vector_dim = 50
373384 for i in range (1 , elements_count + 1 ):
374385 float_array = [random .uniform (10 * i , 1000 * i ) for x in range (vector_dim )]
375386 d_client .vset ().vadd ("myset" , float_array , f"elem_{ i } " )
@@ -396,7 +407,7 @@ def test_vsim_truth_no_thread_enabled(d_client):
396407 )
397408
398409 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 :
400411 if score_with_truth < score_without_truth :
401412 assert False , (
402413 "Score with truth [{score_with_truth}] < score without truth [{score_without_truth}]"
@@ -764,15 +775,15 @@ def test_vset_commands_without_decoding_responces(client):
764775 # test vadd
765776 elements = ["elem1" , "elem2" , "elem3" ]
766777 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 )]
768779 resp = client .vset ().vadd ("myset" , float_array , element = elem )
769780 assert resp == 1
770781
771782 # test vemb
772783 emb = client .vset ().vemb ("myset" , "elem1" )
773784 assert len (emb ) == 8
774785 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 } "
776787
777788 emb_raw = client .vset ().vemb ("myset" , "elem1" , raw = True )
778789 assert emb_raw ["quantization" ] == b"int8"
0 commit comments