Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
cd826dc8
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
260
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
cd826dc8
编写于
7月 15, 2022
作者:
B
binbin
提交者:
GitHub
7月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[skip e2e] Update test cases (#18284)
Signed-off-by:
N
Binbin Lv
<
binbin.lv@zilliz.com
>
上级
b001273c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
80 addition
and
0 deletion
+80
-0
tests/python_client/testcases/test_search.py
tests/python_client/testcases/test_search.py
+80
-0
未找到文件。
tests/python_client/testcases/test_search.py
浏览文件 @
cd826dc8
...
...
@@ -1625,6 +1625,86 @@ class TestCollectionSearch(TestcaseBase):
res
=
res
.
result
()
assert
abs
(
res
[
0
].
distances
[
0
]
-
min
(
distance_0
,
distance_1
))
<=
epsilon
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
@
pytest
.
mark
.
xfail
(
reason
=
"issue 18283"
)
@
pytest
.
mark
.
parametrize
(
"index"
,
[
"BIN_FLAT"
])
def
test_search_binary_substructure_flat_index
(
self
,
nq
,
dim
,
auto_id
,
_async
,
index
,
is_flush
):
"""
target: search binary_collection, and check the result: distance
method: compare the return distance value with value computed with SUBSTRUCTURE
expected: the return distance equals to the computed value
"""
# 1. initialize with binary data
collection_w
,
_
,
binary_raw_vector
,
insert_ids
,
time_stamp
=
self
.
init_collection_general
(
prefix
,
True
,
2
,
is_binary
=
True
,
auto_id
=
auto_id
,
dim
=
dim
,
is_index
=
True
,
is_flush
=
is_flush
)[
0
:
5
]
# 2. create index
default_index
=
{
"index_type"
:
index
,
"params"
:
{
"nlist"
:
128
},
"metric_type"
:
"SUBSTRUCTURE"
}
collection_w
.
create_index
(
"binary_vector"
,
default_index
)
collection_w
.
load
()
# 3. compute the distance
query_raw_vector
,
binary_vectors
=
cf
.
gen_binary_vectors
(
3000
,
dim
)
distance_0
=
cf
.
substructure
(
query_raw_vector
[
0
],
binary_raw_vector
[
0
])
distance_1
=
cf
.
substructure
(
query_raw_vector
[
0
],
binary_raw_vector
[
1
])
# 4. search and compare the distance
search_params
=
{
"metric_type"
:
"SUBSTRUCTURE"
,
"params"
:
{
"nprobe"
:
10
}}
res
=
collection_w
.
search
(
binary_vectors
[:
nq
],
"binary_vector"
,
search_params
,
default_limit
,
"int64 >= 0"
,
_async
=
_async
,
travel_timestamp
=
time_stamp
,
check_task
=
CheckTasks
.
check_search_results
,
check_items
=
{
"nq"
:
nq
,
"ids"
:
insert_ids
,
"limit"
:
2
,
"_async"
:
_async
})[
0
]
if
_async
:
res
.
done
()
res
=
res
.
result
()
assert
abs
(
res
[
0
].
distances
[
0
]
-
min
(
distance_0
,
distance_1
))
<=
epsilon
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
@
pytest
.
mark
.
xfail
(
reason
=
"issue 18283"
)
@
pytest
.
mark
.
parametrize
(
"index"
,
[
"BIN_FLAT"
])
def
test_search_binary_superstructure_flat_index
(
self
,
nq
,
dim
,
auto_id
,
_async
,
index
,
is_flush
):
"""
target: search binary_collection, and check the result: distance
method: compare the return distance value with value computed with SUPERSTRUCTURE
expected: the return distance equals to the computed value
"""
# 1. initialize with binary data
collection_w
,
_
,
binary_raw_vector
,
insert_ids
,
time_stamp
=
self
.
init_collection_general
(
prefix
,
True
,
2
,
is_binary
=
True
,
auto_id
=
auto_id
,
dim
=
dim
,
is_index
=
True
,
is_flush
=
is_flush
)[
0
:
5
]
# 2. create index
default_index
=
{
"index_type"
:
index
,
"params"
:
{
"nlist"
:
128
},
"metric_type"
:
"SUPERSTRUCTURE"
}
collection_w
.
create_index
(
"binary_vector"
,
default_index
)
collection_w
.
load
()
# 3. compute the distance
query_raw_vector
,
binary_vectors
=
cf
.
gen_binary_vectors
(
3000
,
dim
)
distance_0
=
cf
.
superstructure
(
query_raw_vector
[
0
],
binary_raw_vector
[
0
])
distance_1
=
cf
.
superstructure
(
query_raw_vector
[
0
],
binary_raw_vector
[
1
])
# 4. search and compare the distance
search_params
=
{
"metric_type"
:
"SUPERSTRUCTURE"
,
"params"
:
{
"nprobe"
:
10
}}
res
=
collection_w
.
search
(
binary_vectors
[:
nq
],
"binary_vector"
,
search_params
,
default_limit
,
"int64 >= 0"
,
_async
=
_async
,
travel_timestamp
=
time_stamp
,
check_task
=
CheckTasks
.
check_search_results
,
check_items
=
{
"nq"
:
nq
,
"ids"
:
insert_ids
,
"limit"
:
2
,
"_async"
:
_async
})[
0
]
if
_async
:
res
.
done
()
res
=
res
.
result
()
assert
abs
(
res
[
0
].
distances
[
0
]
-
min
(
distance_0
,
distance_1
))
<=
epsilon
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
def
test_search_binary_without_flush
(
self
,
metrics
,
auto_id
):
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录