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

Docarray copy=True #228

Closed
davidbp opened this issue Mar 28, 2022 · 2 comments · Fixed by #239
Closed

Docarray copy=True #228

davidbp opened this issue Mar 28, 2022 · 2 comments · Fixed by #239

Comments

@davidbp
Copy link
Contributor

davidbp commented Mar 28, 2022

@slettner commented that the current behaviour for DocumentArray does work as expected when copy=True is used.

MWE

from docarray import DocumentArray, Document


record = DocumentArray([
    Document(tags={'track_id': 'a'}),
    Document(tags={'track_id': 'b'}),
])

all_tracks_a = DocumentArray(record.find({'tags__track_id': {'$eq': 'a'}}), copy=True)
all_tracks_b = DocumentArray(record.find({'tags__track_id': {'$in': ['a', 'b']}}), copy=True)

result = DocumentArray()

for doc in all_tracks_a:
    doc.tags['label'] = 'l_a'
result.extend(all_tracks_a)
print(result[0].tags['label'])  # >>> 'l_a'

for doc in all_tracks_b:
    doc.tags['label'] = 'l_b'
result.extend(all_tracks_b)
print(result[0].tags['label'])  # >>> 'l_b'
@numb3r3
Copy link
Contributor

numb3r3 commented Mar 28, 2022

I guess it is also caused by the issue of dict-style container. #209

@davidbp
Copy link
Contributor Author

davidbp commented Mar 29, 2022

exactly

@hanxiao hanxiao linked a pull request Mar 30, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants