Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
Fix bug: infer binary_vector failed (#134)
Browse files Browse the repository at this point in the history
* Fix bug: infer binary_vector failed

Signed-off-by: zhenshan.cao <[email protected]>

* Fix bug: use fpath

Signed-off-by: zhenshan.cao <[email protected]>
  • Loading branch information
czs007 authored May 28, 2021
1 parent 1fdebfc commit d7732a3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions examples/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
def gen_default_fields():
default_fields = [
FieldSchema(name="int64", dtype=DataType.INT64, is_primary=False),
FieldSchema(name="float", dtype=DataType.FLOAT),
FieldSchema(name="double", dtype=DataType.DOUBLE),
FieldSchema(name=default_float_vec_field_name, dtype=DataType.FLOAT_VECTOR, dim=default_dim)
]
default_schema = CollectionSchema(fields=default_fields, description="test collection")
Expand All @@ -74,7 +74,7 @@ def gen_default_fields():
def gen_default_fields_with_primary_key_1():
default_fields = [
FieldSchema(name="int64", dtype=DataType.INT64, is_primary=True),
FieldSchema(name="float", dtype=DataType.FLOAT),
FieldSchema(name="double", dtype=DataType.DOUBLE),
FieldSchema(name=default_float_vec_field_name, dtype=DataType.FLOAT_VECTOR, dim=default_dim)
]
default_schema = CollectionSchema(fields=default_fields, description="test collection")
Expand All @@ -84,7 +84,7 @@ def gen_default_fields_with_primary_key_1():
def gen_default_fields_with_primary_key_2():
default_fields = [
FieldSchema(name="int64", dtype=DataType.INT64),
FieldSchema(name="float", dtype=DataType.FLOAT),
FieldSchema(name="double", dtype=DataType.DOUBLE),
FieldSchema(name=default_float_vec_field_name, dtype=DataType.FLOAT_VECTOR, dim=default_dim)
]
default_schema = CollectionSchema(fields=default_fields, description="test collection", primary_field="int64")
Expand All @@ -94,7 +94,7 @@ def gen_default_fields_with_primary_key_2():
def gen_binary_schema():
binary_fields = [
FieldSchema(name="int64", dtype=DataType.INT64, is_primary=False),
FieldSchema(name="float", dtype=DataType.FLOAT),
FieldSchema(name="double", dtype=DataType.DOUBLE),
FieldSchema(name=default_binary_vec_field_name, dtype=DataType.BINARY_VECTOR, dim=default_dim)
]
default_schema = CollectionSchema(fields=binary_fields, description="test collection")
Expand Down Expand Up @@ -226,4 +226,4 @@ def test_specify_primary_key():
test_collection_with_data()
test_create_index_float_vector()
test_create_index_binary_vector()
# test_specify_primary_key()
test_specify_primary_key()
2 changes: 1 addition & 1 deletion examples/hello_milvus.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def hello_milvus():
dim = 128
default_fields = [
schema.FieldSchema(name="count", dtype=DataType.INT64, is_primary=False),
schema.FieldSchema(name="score", dtype=DataType.FLOAT),
schema.FieldSchema(name="score", dtype=DataType.DOUBLE),
schema.FieldSchema(name="float_vector", dtype=DataType.FLOAT_VECTOR, dim=dim)
]
default_schema = schema.CollectionSchema(fields=default_fields, description="test collection")
Expand Down
4 changes: 2 additions & 2 deletions pymilvus_orm/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def infer_dtype_by_scaladata(data):
return DataType.BOOL
if isinstance(data, np.bool_):
return DataType.BOOL
if isinstance(data, bytes):
return DataType.BINARY_VECTOR
if is_float(data):
return DataType.DOUBLE

Expand All @@ -131,8 +133,6 @@ def infer_dtype_bydata(data):
d_type = dtype_str_map.get(type_str, DataType.UNKNOWN)
if is_numeric_datatype(d_type):
d_type = DataType.FLOAT_VECTOR
elif type_str in ("bytes",):
d_type = DataType.BINARY_VECTOR
else:
d_type = DataType.UNKNOWN

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

def simple_parse_requirements(fpath):
requirements = []
with open("requirements.txt", 'r') as f:
with open(fpath, 'r') as f:
for line in f.readlines():
if line.startswith("--"):
continue
Expand Down
2 changes: 1 addition & 1 deletion tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_infer_dtype_bydata(self):
[True],
[1.0, 2.0],
["abc"],
[bytes("abc", encoding='ascii'), bytes("def", encoding='ascii')],
bytes("abc", encoding='ascii'),
1,
True,
"abc",
Expand Down

0 comments on commit d7732a3

Please sign in to comment.