Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 363a2fd

Browse filesBrowse files
authored
fix: del remove attribute (#304)
* fix: del remove attribute * test: add test that covers fix
1 parent 923c2ce commit 363a2fd
Copy full SHA for 363a2fd

2 files changed

+26Lines changed: 26 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docarray/array/mixins/delitem.py‎

Copy file name to clipboardExpand all lines: docarray/array/mixins/delitem.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def __delitem__(self, index: 'DocumentArrayIndexType'):
5656
for _d in self[index[0]]:
5757
for _aa in _attrs:
5858
self._set_doc_attr_by_id(_d.id, _aa, None)
59+
_d.pop(_aa)
60+
5961
elif isinstance(index[0], bool):
6062
self._del_docs_by_mask(index)
6163
elif isinstance(index[0], int):
Collapse file

‎tests/unit/array/mixins/test_del.py‎

Copy file name to clipboardExpand all lines: tests/unit/array/mixins/test_del.py
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from docarray import DocumentArray, Document
44
from docarray.array.weaviate import DocumentArrayWeaviate
5+
import numpy as np
56

67

78
@pytest.fixture()
@@ -81,3 +82,26 @@ def test_del_da_persist(da_cls, config, persist, docs, start_storage):
8182
assert len(da2) == len(docs)
8283
else:
8384
assert len(da2) == 0
85+
86+
87+
def test_del_da_attribute():
88+
89+
da = DocumentArray(
90+
[
91+
Document(embedding=np.array([1, 2, 3]), text='d1'),
92+
Document(embedding=np.array([1, 2, 3]), text='d2'),
93+
]
94+
)
95+
96+
q = DocumentArray(
97+
[
98+
Document(embedding=np.array([4, 5, 6]), text='q1'),
99+
Document(embedding=np.array([2, 3, 4]), text='q1'),
100+
]
101+
)
102+
103+
da.match(q)
104+
del da[...][:, 'embedding']
105+
106+
for d in da:
107+
assert d.embedding is None

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.