Skip to content

Commit

Permalink
Improve: More flexibility for Python args
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Jul 23, 2023
1 parent 4863bea commit 6aa06cb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/usearch/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ def metadata(path: os.PathLike) -> IndexMetadata:

@staticmethod
def restore(path: os.PathLike, view: bool = False) -> Index:
if not os.path.exists(path):
return None
meta = Index.metadata(path)
bits_per_scalar = {
ScalarKind.F8: 8,
Expand Down Expand Up @@ -352,11 +354,11 @@ def add(
else:
labels = start_id
else:
if isinstance(labels, np.ndarray):
if isinstance(labels, Iterable):
if not is_multiple:
labels = int(labels[0])
else:
labels = labels.astype(Label)
labels = np.array(labels).astype(Label)
count_labels = len(labels) if isinstance(labels, Iterable) else 1
assert count_labels == count_vectors

Expand Down

0 comments on commit 6aa06cb

Please sign in to comment.