File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -110,11 +110,10 @@ def find_ids_by_score_numpy(self) -> np.array:
110110 try :
111111 c_id_array : OBX_id_array = c_id_array_p .contents
112112 c_count = c_id_array .count
113- if c_count == 0 :
114- return []
115- c_ids = ctypes .cast (c_id_array .ids , ctypes .POINTER (obx_id ))
116113 numpy_array = np .empty (c_count , dtype = np .uint64 )
117- ctypes .memmove (numpy_array .ctypes .data , c_ids , numpy_array .nbytes )
114+ if c_count > 0 :
115+ c_ids = ctypes .cast (c_id_array .ids , ctypes .POINTER (obx_id ))
116+ ctypes .memmove (numpy_array .ctypes .data , c_ids , numpy_array .nbytes )
118117 return numpy_array
119118 finally :
120119 obx_id_array_free (c_id_array_p )
Original file line number Diff line number Diff line change @@ -192,6 +192,16 @@ def _test_combined_nn_search(distance_type: VectorDistanceType = VectorDistanceT
192192 assert search_results [0 ] == 4
193193 assert search_results [1 ] == 5
194194
195+ # Test empty result
196+ query .offset (999 )
197+ assert len (query .find_ids ()) == 0
198+ assert len (query .find_ids_with_scores ()) == 0
199+ assert len (query .find_ids_by_score ()) == 0
200+ numpy_result = query .find_ids_by_score_numpy ()
201+ assert numpy_result .size == 0
202+ assert str (numpy_result .dtype ) == "uint64"
203+ assert len (numpy_result ) == 0
204+
195205
196206def test_combined_nn_search ():
197207 """ Tests NN search combined with regular query conditions, offset and limit. """
You can’t perform that action at this time.
0 commit comments