Skip to content

Commit

Permalink
fix view float32 in insert rows
Browse files Browse the repository at this point in the history
Signed-off-by: yangxuan <xuan.yang@zilliz.com>
  • Loading branch information
XuanYang-cn committed Apr 23, 2024
1 parent ba936cd commit 6ffd75a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions examples/hello_milvus.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@

insert_result = hello_milvus.insert(entities)

row = {
"pk": "19530",
"random": 0.5,
"embeddings": rng.random((1, dim), np.float32)[0]
}
hello_milvus.insert(row)

hello_milvus.flush()
print(f"Number of entities in Milvus: {hello_milvus.num_entities}") # check the num_entities

Expand Down
2 changes: 1 addition & 1 deletion pymilvus/client/entity_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def pack_field_value_to_field_data(
raise ParamError(
message="invalid input for float32 vector, expect np.ndarray with dtype=float32"
)
f_value = field_value.view(np.float32).tolist()
f_value = field_value.tolist()

field_data.vectors.dim = len(f_value)
field_data.vectors.float_vector.data.extend(f_value)
Expand Down

0 comments on commit 6ffd75a

Please sign in to comment.