Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: yangxuan <[email protected]>
  • Loading branch information
XuanYang-cn committed Apr 2, 2024
1 parent 273abe5 commit 67a7914
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
12 changes: 10 additions & 2 deletions pymilvus/client/entity_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,20 @@ def pack_field_value_to_field_data(field_value: Any, field_data: Any, field_info
field_data.vectors.dim = len(field_value) * 8
field_data.vectors.binary_vector += bytes(field_value)
elif field_type == DataType.FLOAT16_VECTOR:
v_bytes = bytes(field_value) if not isinstance(field_value, np.ndarray) else field_value.view(np.uint8).tobytes()
v_bytes = (
bytes(field_value)
if not isinstance(field_value, np.ndarray)
else field_value.view(np.uint8).tobytes()
)

field_data.vectors.dim = len(v_bytes) // 2
field_data.vectors.float16_vector += v_bytes
elif field_type == DataType.BFLOAT16_VECTOR:
v_bytes = bytes(field_value) if not isinstance(field_value, np.ndarray) else field_value.view(np.uint8).tobytes()
v_bytes = (
bytes(field_value)
if not isinstance(field_value, np.ndarray)
else field_value.view(np.uint8).tobytes()
)

field_data.vectors.dim = len(v_bytes) // 2
field_data.vectors.bfloat16_vector += v_bytes
Expand Down
1 change: 0 additions & 1 deletion pymilvus/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def traverse_rows_info(fields_info: Any, entities: List):

field_name = field["name"]
location[field_name] = i
field_type = field["type"]

if field.get("is_dynamic", False):
is_dynamic = True
Expand Down
8 changes: 4 additions & 4 deletions pymilvus/orm/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import pandas as pd

from pymilvus.client import entity_helper
from pymilvus.client.types import DataType
from pymilvus.exceptions import (
DataNotMatchException,
DataTypeNotSupportException,
ExceptionsMessage,
UpsertAutoIDTrueException,
)
from pymilvus.client.types import DataType

from .schema import CollectionSchema

Expand Down Expand Up @@ -75,9 +75,9 @@ def prepare_insert_data(
if isinstance(f_data, np.ndarray):
d = f_data.tolist()

elif (
isinstance(f_data[0], np.ndarray)
and field.dtype in (DataType.FLOAT16_VECTOR, DataType.BFLOAT16_VECTOR)
elif isinstance(f_data[0], np.ndarray) and field.dtype in (
DataType.FLOAT16_VECTOR,
DataType.BFLOAT16_VECTOR,
):
d = [bytes(ndarr.view(np.uint8).tolist()) for ndarr in f_data]

Expand Down

0 comments on commit 67a7914

Please sign in to comment.