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
2 changes: 1 addition & 1 deletion docarray/base_doc/mixins/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _group_fields(doc: 'UpdateMixin') -> _FieldGroups:
dict_fields.append(field_name)
else:
v = getattr(doc, field_name)
if v:
if v is not None:
if isinstance(v, UpdateMixin):
nested_docs_fields.append(field_name)
else:
Expand Down
17 changes: 17 additions & 0 deletions tests/units/util/test_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,20 @@ def test_reduce_all(doc1, doc2):
assert len(merged_doc.matches_with_same_id[0].matches) == 2
assert merged_doc.inner_doc.integer == 3
assert merged_doc.inner_doc.inner_list == ['c', 'd', 'a', 'b', 'c', 'd', 'a', 'b']


def test_update_ndarray():
from docarray.typing import NdArray

import numpy as np

class MyDoc(BaseDoc):
embedding: NdArray[128]

embedding1 = np.random.rand(128)
embedding2 = np.random.rand(128)

doc1 = MyDoc(id='0', embedding=embedding1)
doc2 = MyDoc(id='0', embedding=embedding2)
doc1.update(doc2)
assert (doc1.embedding == embedding2).all()