Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docarray/index/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,3 +900,6 @@ def _dict_list_to_docarray(self, dict_list: Sequence[Dict[str, Any]]) -> DocList
doc_list = [self._convert_dict_to_doc(doc_dict, self._schema) for doc_dict in dict_list] # type: ignore
docs_cls = DocList.__class_getitem__(cast(Type[BaseDoc], self._schema))
return docs_cls(doc_list)

def __len__(self) -> int:
return self.num_docs()
8 changes: 7 additions & 1 deletion tests/index/base_classes/test_base_doc_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def python_type_to_db_type(self, x):
return str

_index = _identity
num_docs = _identity
num_docs = lambda n: 3
_del_items = _identity
_get_items = _identity
execute_query = _identity
Expand Down Expand Up @@ -572,3 +572,9 @@ def test_validate_search_fields():
# 'ten' is not a valid field
with pytest.raises(ValueError):
index._validate_search_field('ten')


def test_len():
store = DummyDocIndex[SimpleDoc]()
count = len(store)
assert count == 3