Skip to content

fix: id_to_index initialization#35

Merged
hanxiao merged 1 commit intomainfrom
fix-empty-docs
Jan 12, 2022
Merged

fix: id_to_index initialization#35
hanxiao merged 1 commit intomainfrom
fix-empty-docs

Conversation

@numb3r3
Copy link
Copy Markdown
Contributor

@numb3r3 numb3r3 commented Jan 12, 2022

An empty DA instance cannot be assigned to a new DA instance, as shown in the following:

from docarray import Document, DocumentArray

matches = DocumentArray()

query = Document()
query.matches = matches

yields

AttributeError: 'DocumentArray' object has no attribute '_id_to_index'

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 12, 2022

Codecov Report

Merging #35 (0e2a524) into main (3573d82) will increase coverage by 0.31%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #35      +/-   ##
==========================================
+ Coverage   82.94%   83.26%   +0.31%     
==========================================
  Files          67       67              
  Lines        3137     3149      +12     
==========================================
+ Hits         2602     2622      +20     
+ Misses        535      527       -8     
Flag Coverage Δ
docarray 83.26% <100.00%> (+0.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
docarray/__init__.py 100.00% <100.00%> (ø)
docarray/array/document.py 85.64% <100.00%> (+1.85%) ⬆️
docarray/array/mixins/getattr.py 81.81% <100.00%> (-9.10%) ⬇️
docarray/array/mixins/io/binary.py 95.55% <100.00%> (+0.31%) ⬆️
docarray/array/mixins/match.py 92.94% <100.00%> (ø)
docarray/array/mixins/plot.py 69.28% <100.00%> (ø)
docarray/document/mixins/attribute.py 100.00% <100.00%> (ø)
docarray/document/mixins/mesh.py 93.33% <100.00%> (+16.86%) ⬆️
docarray/document/mixins/porting.py 92.59% <100.00%> (+0.92%) ⬆️
docarray/proto/io/ndarray.py 94.78% <100.00%> (+0.09%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f0d222d...0e2a524. Read the comment docs.

@numb3r3 numb3r3 changed the title fix: _id_to_index initialize of empty doc array fix: id_to_index initialization Jan 12, 2022
@davidbp
Copy link
Copy Markdown
Contributor

davidbp commented Jan 12, 2022

You mean a Document can' t have a DocumentArray in matches?

This works

from docarray import Document, DocumentArray
matches = DocumentArray()
query = DocumentArray()
query.matches = matches

@numb3r3
Copy link
Copy Markdown
Contributor Author

numb3r3 commented Jan 12, 2022

You mean a Document can' t have a DocumentArray in matches?

Not exactly, I mean "a Document can't have a empty DocumentArray in maches"

@hanxiao hanxiao merged commit 0abf974 into main Jan 12, 2022
@hanxiao hanxiao deleted the fix-empty-docs branch January 12, 2022 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants