Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

Commit d1fb63d

Browse files
author
Joan Fontanals Martinez
committed
fix: fix update with embeddings
1 parent e66bf10 commit d1fb63d

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎docarray/base_doc/mixins/update.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def _group_fields(doc: 'UpdateMixin') -> _FieldGroups:
120120
dict_fields.append(field_name)
121121
else:
122122
v = getattr(doc, field_name)
123-
if v:
123+
if v is not None:
124124
if isinstance(v, UpdateMixin):
125125
nested_docs_fields.append(field_name)
126126
else:

‎tests/units/util/test_reduce.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,20 @@ def test_reduce_all(doc1, doc2):
120120
assert len(merged_doc.matches_with_same_id[0].matches) == 2
121121
assert merged_doc.inner_doc.integer == 3
122122
assert merged_doc.inner_doc.inner_list == ['c', 'd', 'a', 'b', 'c', 'd', 'a', 'b']
123+
124+
125+
def test_update_ndarray():
126+
from docarray.typing import NdArray
127+
128+
import numpy as np
129+
130+
class MyDoc(BaseDoc):
131+
embedding: NdArray[128]
132+
133+
embedding1 = np.random.rand(128)
134+
embedding2 = np.random.rand(128)
135+
136+
doc1 = MyDoc(id='0', embedding=embedding1)
137+
doc2 = MyDoc(id='0', embedding=embedding2)
138+
doc1.update(doc2)
139+
assert (doc1.embedding == embedding2).all()

0 commit comments

Comments
 (0)