Skip to content
Merged
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
13 changes: 2 additions & 11 deletions docarray/array/chunk.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import itertools
from typing import (
TYPE_CHECKING,
Generator,
Iterator,
Sequence,
Iterable,
)

from .document import DocumentArray
from .memory import DocumentArrayInMemory

if TYPE_CHECKING:
Expand All @@ -31,12 +27,7 @@ def __init__(self, docs, reference_doc: 'Document'):
"""
self._ref_doc = reference_doc
super().__init__(docs)
if (
isinstance(
docs, (DocumentArray, Sequence, Generator, Iterator, itertools.chain)
)
and self._ref_doc is not None
):
if isinstance(docs, Iterable) and self._ref_doc is not None:
for d in docs:
d.parent_id = self._ref_doc.id
d.granularity = self._ref_doc.granularity + 1
Expand Down
13 changes: 2 additions & 11 deletions docarray/array/match.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import itertools
from typing import (
TYPE_CHECKING,
Generator,
Iterator,
Sequence,
Iterable,
)

from .document import DocumentArray
from .memory import DocumentArrayInMemory

if TYPE_CHECKING:
Expand All @@ -25,12 +21,7 @@ class MatchArray(DocumentArrayInMemory):
def __init__(self, docs, reference_doc: 'Document'):
self._ref_doc = reference_doc
super().__init__(docs)
if (
isinstance(
docs, (DocumentArray, Sequence, Generator, Iterator, itertools.chain)
)
and self._ref_doc is not None
):
if isinstance(docs, Iterable) and self._ref_doc is not None:
for d in docs:
d.adjacency = self._ref_doc.adjacency + 1

Expand Down
11 changes: 3 additions & 8 deletions docarray/array/storage/annlite/backend.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import itertools
import numpy as np
from dataclasses import dataclass, asdict, field
from typing import (
Union,
Dict,
Optional,
TYPE_CHECKING,
Sequence,
Generator,
Iterator,
Iterable,
)

from ..base.backend import BaseBackendMixin
Expand All @@ -27,7 +24,7 @@ class AnnliteConfig:


class BackendMixin(BaseBackendMixin):
"""Provide necessary functions to enable this storage backend. """
"""Provide necessary functions to enable this storage backend."""

def _map_embedding(self, embedding: 'ArrayType') -> 'ArrayType':
if embedding is None:
Expand Down Expand Up @@ -77,9 +74,7 @@ def _init_storage(

self.clear()

if isinstance(
_docs, (DocumentArray, Sequence, Generator, Iterator, itertools.chain)
):
if isinstance(_docs, Iterable):
self.extend(_docs)
elif isinstance(_docs, Document):
self.append(_docs)
Expand Down
8 changes: 2 additions & 6 deletions docarray/array/storage/memory/backend.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import itertools
from typing import (
Generator,
Iterator,
Dict,
Sequence,
Optional,
TYPE_CHECKING,
Iterable,
)

from ..base.backend import BaseBackendMixin
Expand Down Expand Up @@ -36,7 +32,7 @@ def _init_storage(
return
elif isinstance(
_docs,
(DocumentArray, Sequence, Generator, Iterator, itertools.chain),
Iterable,
):
if copy:
for doc in _docs:
Expand Down
1 change: 0 additions & 1 deletion docarray/array/storage/memory/getsetdel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import (
Sequence,
Iterable,
Any,
)

from ..base.getsetdel import BaseGetSetDelMixin
Expand Down
9 changes: 2 additions & 7 deletions docarray/array/storage/qdrant/backend.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import itertools
import uuid
from dataclasses import dataclass, field
from typing import (
Optional,
TYPE_CHECKING,
Union,
Dict,
Sequence,
Generator,
Iterator,
Iterable,
List,
)

Expand Down Expand Up @@ -105,9 +102,7 @@ def _init_storage(
# is provided, :class:`DocumentArraySqlite` will clear the existing
# table and load the given `docs`
self.clear()
if isinstance(
docs, (DocumentArray, Sequence, Generator, Iterator, itertools.chain)
):
if isinstance(docs, Iterable):
self.extend(docs)
elif isinstance(docs, Document):
self.append(docs)
Expand Down
9 changes: 2 additions & 7 deletions docarray/array/storage/sqlite/backend.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import itertools
import sqlite3
import warnings
from dataclasses import dataclass, field
from tempfile import NamedTemporaryFile
from typing import (
Generator,
Iterator,
Iterable,
Dict,
Sequence,
Optional,
TYPE_CHECKING,
Union,
Expand Down Expand Up @@ -116,9 +113,7 @@ def _init_storage(

if _docs is None:
return
elif isinstance(
_docs, (DocumentArray, Sequence, Generator, Iterator, itertools.chain)
):
elif isinstance(_docs, Iterable):
self.clear()
self.extend(_docs)
else:
Expand Down
10 changes: 2 additions & 8 deletions docarray/array/storage/weaviate/backend.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import itertools
import uuid
from dataclasses import dataclass, field
from typing import (
Generator,
Iterator,
Iterable,
Dict,
Sequence,
Optional,
TYPE_CHECKING,
Union,
Expand All @@ -15,7 +12,6 @@

import numpy as np
import weaviate
from weaviate.auth import AuthCredentials

from ..base.backend import BaseBackendMixin
from .... import Document
Expand Down Expand Up @@ -90,9 +86,7 @@ def _init_storage(
# table and load the given `docs`
if _docs is None:
return
elif isinstance(
_docs, (DocumentArray, Sequence, Generator, Iterator, itertools.chain)
):
elif isinstance(_docs, Iterable):
self.clear()
self.extend(_docs)
else:
Expand Down
2 changes: 1 addition & 1 deletion docarray/array/storage/weaviate/getsetdel.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _del_doc_by_id(self, _id: str):
self._client.data_object.delete(wid)

def _clear_storage(self):
""" Concrete implementation of base class' ``_clear_storage``"""
"""Concrete implementation of base class' ``_clear_storage``"""
if self._class_name:
self._client.schema.delete_class(self._class_name)
self._client.schema.delete_class(self._meta_name)
Expand Down