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:
110
110
try :
111
111
c_id_array : OBX_id_array = c_id_array_p .contents
112
112
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 ))
116
113
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 )
118
117
return numpy_array
119
118
finally :
120
119
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
192
192
assert search_results [0 ] == 4
193
193
assert search_results [1 ] == 5
194
194
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
+
195
205
196
206
def test_combined_nn_search ():
197
207
""" Tests NN search combined with regular query conditions, offset and limit. """
You can’t perform that action at this time.
0 commit comments