未验证 提交 786c335b 编写于 作者: B binbin 提交者: GitHub

Add test cases for collection search (#5552)

* [skip ci] Add test cases for collection search.
Signed-off-by: NBinbin Lv <binbin.lv@zilliz.com>

* [skip ci] Resolve comments for PR 5552.
Signed-off-by: NBinbin Lv <binbin.lv@zilliz.com>
上级 f791ccb2
......@@ -9,6 +9,8 @@ from pymilvus_orm.types import DataType
from pymilvus_orm.schema import CollectionSchema, FieldSchema
from common import common_type as ct
from utils.util_log import test_log as log
import threading
import traceback
"""" Methods of processing data """
......@@ -92,13 +94,13 @@ def gen_default_dataframe_data(nb=ct.default_nb, dim=ct.default_dim):
def gen_default_binary_dataframe_data(nb=ct.default_nb, dim=ct.default_dim):
int_values = pd.Series(data=[i for i in range(nb)])
float_values = pd.Series(data=[float(i) for i in range(nb)], dtype="float32")
_, binary_vec_values = gen_binary_vectors(nb, dim)
binary_raw_values, binary_vec_values = gen_binary_vectors(nb, dim)
df = pd.DataFrame({
ct.default_int64_field_name: int_values,
ct.default_float_field_name: float_values,
ct.default_binary_vec_field_name: binary_vec_values
})
return df
return df, binary_raw_values
def gen_default_list_data(nb=ct.default_nb, dim=ct.default_dim):
......@@ -180,6 +182,30 @@ def gen_invalid_dataframe():
]
return dfs
def jaccard(x, y):
x = np.asarray(x, np.bool)
y = np.asarray(y, np.bool)
return 1 - np.double(np.bitwise_and(x, y).sum()) / np.double(np.bitwise_or(x, y).sum())
def hamming(x, y):
x = np.asarray(x, np.bool)
y = np.asarray(y, np.bool)
return np.bitwise_xor(x, y).sum()
def tanimoto(x, y):
x = np.asarray(x, np.bool)
y = np.asarray(y, np.bool)
return -np.log2(np.double(np.bitwise_and(x, y).sum()) / np.double(np.bitwise_or(x, y).sum()))
def substructure(x, y):
x = np.asarray(x, np.bool)
y = np.asarray(y, np.bool)
return 1 - np.double(np.bitwise_and(x, y).sum()) / np.count_nonzero(y)
def superstructure(x, y):
x = np.asarray(x, np.bool)
y = np.asarray(y, np.bool)
return 1 - np.double(np.bitwise_and(x, y).sum()) / np.count_nonzero(x)
def modify_file(file_name_list, input_content=""):
if not isinstance(file_name_list, list):
......
......@@ -9,6 +9,9 @@ default_drop_interval = 3
default_dim = 128
default_nb = 1200
default_top_k = 10
default_nq = 2
default_limit = 10
default_search_params = {"metric_type": "L2", "params": {"nprobe": 10}}
max_top_k = 16384
max_partition_num = 4096 # 256
default_segment_row_limit = 1000
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册