Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: single doc set in docarray #42

Merged
merged 5 commits into from
Jan 13, 2022
Merged

fix: single doc set in docarray #42

merged 5 commits into from
Jan 13, 2022

Conversation

davidbp
Copy link
Contributor

@davidbp davidbp commented Jan 12, 2022

Currently setting for example .text the attribute for a concrete Document in a DocumentArray results to setting the first character in the string.

# this works as expected in master
from docarray import Document, DocumentArray
da = DocumentArray([Document(),Document(), Document()])
da[[0,1],'text'] = ['jina','jana']
print(da[:,'text'])

# this does NOT work as expected in master
from docarray import Document, DocumentArray
da = DocumentArray([Document(),Document(), Document()])
da[[0],'text'] = 'jina'
print(da[:,'text'])

# this does NOT work as expected in master
import numpy as np
from docarray import Document, DocumentArray
da = DocumentArray([Document(),Document(), Document()])
da[[0],'id'] = '1234'
print(da[:,'id'])

In master

['jina', 'jana', '']
['j', '', '']
['1', 'b6ac7ce073ba11ecbdc7787b8ab3f5de', 'b6ac7d3073ba11ecbdc7787b8ab3f5de']

This happens because the setter has the sets the values in for _d, _vv in zip(_docs, _v) and when the input data is an iterable this is not probably what the user would expect

In this PR

['jina', 'jana', '']
['jina', '', '']
['1234', '92c2521e73ba11eca885787b8ab3f5de', '92c2526473ba11eca885787b8ab3f5de']

@codecov
Copy link

codecov bot commented Jan 12, 2022

Codecov Report

Merging #42 (ae67c85) into main (699c041) will decrease coverage by 0.21%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #42      +/-   ##
==========================================
- Coverage   82.80%   82.58%   -0.22%     
==========================================
  Files          67       67              
  Lines        3193     3216      +23     
==========================================
+ Hits         2644     2656      +12     
- Misses        549      560      +11     
Flag Coverage Δ
docarray 82.58% <66.66%> (-0.22%) ⬇️

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

Impacted Files Coverage Δ
docarray/types.py 0.00% <0.00%> (ø)
docarray/array/document.py 86.97% <100.00%> (+0.11%) ⬆️
docarray/document/mixins/plot.py 69.56% <0.00%> (-23.30%) ⬇️
docarray/array/mixins/plot.py 60.89% <0.00%> (+0.09%) ⬆️
docarray/helper.py 65.58% <0.00%> (+1.29%) ⬆️

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 699c041...ae67c85. Read the comment docs.

Copy link
Member

@hanxiao hanxiao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will take this branch

Copy link
Member

@hanxiao hanxiao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to go

@hanxiao hanxiao merged commit 97725ed into main Jan 13, 2022
@hanxiao hanxiao deleted the fix-single-string-setter branch January 13, 2022 11:28
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.

None yet

2 participants