Skip to content
Merged
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
9 changes: 8 additions & 1 deletion examples/hello_milvus.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,18 @@
# provide the pk field because `auto_id` is set to False
[str(i) for i in range(num_entities)],
rng.random(num_entities).tolist(), # field random, only supports list
rng.random((num_entities, dim)), # field embeddings, supports numpy.ndarray and list
rng.random((num_entities, dim), np.float32), # field embeddings, supports numpy.ndarray and list
]

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
2 changes: 1 addition & 1 deletion pymilvus/orm/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def prepare_insert_data(
field.name, "np.float32/np.float64", f_data.dtype
)
)
d = f_data.view(np.float32).tolist()
d = f_data.tolist()

elif isinstance(f_data[0], np.ndarray):
for ndarr in f_data:
Expand Down