Skip to content

Commit

Permalink
fix: more useful default (#1917)
Browse files Browse the repository at this point in the history
* fix: more useful default

* fix: add unit test

Co-authored-by: Nan Wang <[email protected]>
  • Loading branch information
maximilianwerk and nan-wang authored Feb 10, 2021
1 parent 5fb7ea8 commit e0e1c13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jina/drivers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class KVSearchDriver(BaseSearchDriver):
- K is the top-k
"""

def __init__(self, is_merge: bool = False, traversal_paths: Tuple[str] = ('m'), *args, **kwargs):
def __init__(self, is_merge: bool = True, traversal_paths: Tuple[str] = ('m'), *args, **kwargs):
"""Construct the driver.
:param is_merge: when set to true the retrieved docs are merged into current message using :meth:`MergeFrom`,
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/types/document/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,16 @@ def test_doc_plot():
docs[0].matches.append(docs[3])

assert docs[0]._mermaid_to_url('svg')


@pytest.mark.skip('MergeFrom will duplicate embedding.shape if embedding is already there')
def test_mergefrom():
d1 = Document(text='d1', embedding=np.random.rand(3))
d1.matches.append(Document(text='m11'))
d1.matches.append(Document(text='m12'))
d2 = Document(text='d2', embedding=np.random.rand(3))
d2.matches.append(Document(text='m21'))
d1.MergeFrom(d2)
assert len(d1.matches) == 3
assert d1.text == d2.text
assert d1.embedding.shape == (3, )

0 comments on commit e0e1c13

Please sign in to comment.