test: modify the order function in test cases (#31680)

issue: #30694

Signed-off-by: binbin lv <binbin.lv@zilliz.com>
pull/31702/head
binbin 2024-03-28 17:37:10 +08:00 committed by GitHub
parent b99c46246c
commit 6c6764bcad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 6 deletions

View File

@ -11886,9 +11886,9 @@ class TestCollectionHybridSearchValid(TestcaseBase):
req = AnnSearchRequest(**search_param)
req_list.append(req)
# 4. hybrid search
res = collection_w.hybrid_search(req_list, WeightedRanker(*weights), 10)
is_sorted_decrease = lambda lst: all(lst[i]['distance'] >= lst[i+1]['distance'] for i in range(len(lst)-1))
assert is_sorted_decrease(res[0])
res = collection_w.hybrid_search(req_list, WeightedRanker(*weights), 10)[0]
is_sorted_ascend = lambda lst: all(lst[i] <= lst[i+1] for i in range(len(lst)-1))
assert is_sorted_ascend(res[0].distances)
@pytest.mark.tags(CaseLabel.L1)
def test_hybrid_search_result_order(self):
@ -11917,6 +11917,6 @@ class TestCollectionHybridSearchValid(TestcaseBase):
req = AnnSearchRequest(**search_param)
req_list.append(req)
# 4. hybrid search
res = collection_w.hybrid_search(req_list, WeightedRanker(*weights), 10)
is_sorted_ascend = lambda lst: all(lst[i]['distance'] <= lst[i+1]['distance'] for i in range(len(lst)-1))
assert is_sorted_ascend(res[0])
res = collection_w.hybrid_search(req_list, WeightedRanker(*weights), 10)[0]
is_sorted_descend = lambda lst: all(lst[i] >= lst[i+1] for i in range(len(lst)-1))
assert is_sorted_descend(res[0].distances)