Skip to content

Commit

Permalink
fix sparse: accpet int/float wrapped in string (milvus-io#2094)
Browse files Browse the repository at this point in the history
when providing sparse float vector using python dict/list, we allow the
index/value to be wrapped in string:

both `{1:0.1, 2:0.2}` and `{1:"0.1", "2": 0.2}` are acceptable. this is
defined in `entity_is_sparse_matrix` but `sparse_rows_to_proto` doesn't
respect this. This pr fixes this.

Signed-off-by: Buqian Zheng <[email protected]>
  • Loading branch information
zhengbuqian authored May 15, 2024
1 parent 3198bd2 commit 2772640
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pymilvus/client/entity_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def sparse_float_row_to_bytes(indices: Iterable[int], values: Iterable[float]):
values = []
row = row_data.items() if isinstance(row_data, dict) else row_data
for index, value in row:
indices.append(index)
values.append(value)
indices.append(int(index))
values.append(float(value))
result.contents.append(sparse_float_row_to_bytes(indices, values))
dim = max(dim, indices[-1] + 1)
result.dim = dim
Expand Down

0 comments on commit 2772640

Please sign in to comment.