Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pymilvus/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,18 @@ def check_invalid_binary_vector(entities: List) -> bool:
if not isinstance(entity["values"], list) or len(entity["values"]) == 0:
return False

if not isinstance(entity["values"][0], bytes):
return False

dim = len(entity["values"][0]) * 8
if dim == 0:
return False

for values in entity["values"]:
if len(values) * 8 != dim:
return False
if not isinstance(values, bytes):
return False
if len(values) * 8 != dim:
Comment thread
lokeshramchand-ctrl marked this conversation as resolved.
return False
return True


Expand Down
12 changes: 12 additions & 0 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ def test_empty_values(self):
entities = [{"type": DataType.BINARY_VECTOR, "values": []}]
assert utils.check_invalid_binary_vector(entities) is False

def test_non_sized_value(self):
entities = [{"type": DataType.BINARY_VECTOR, "values": [b"\x00\x01", None]}]
assert utils.check_invalid_binary_vector(entities) is False
Comment thread
lokeshramchand-ctrl marked this conversation as resolved.

def test_non_sized_first_value(self):
entities = [{"type": DataType.BINARY_VECTOR, "values": [None, b"\x00\x01"]}]
assert utils.check_invalid_binary_vector(entities) is False

def test_all_non_sized_values(self):
entities = [{"type": DataType.BINARY_VECTOR, "values": [1, 2]}]
assert utils.check_invalid_binary_vector(entities) is False


class TestSparseParseSingleRow:
def test_basic_parsing(self):
Expand Down