usearch 0.16.1 → 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +1 -1
- package/conanfile.py +1 -1
- package/package.json +1 -1
- package/python/usearch/eval.py +15 -6
package/Cargo.toml
CHANGED
package/conanfile.py
CHANGED
|
@@ -4,7 +4,7 @@ from conans import ConanFile
|
|
|
4
4
|
class USearchConan(ConanFile):
|
|
5
5
|
|
|
6
6
|
name = 'USearch'
|
|
7
|
-
version = '0.16.
|
|
7
|
+
version = '0.16.3'
|
|
8
8
|
license = 'Apache 2.0'
|
|
9
9
|
url = 'https://github.com/unum-cloud/usearch'
|
|
10
10
|
description = 'Smaller & Faster Single-File Vector Search Engine from Unum'
|
package/package.json
CHANGED
package/python/usearch/eval.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
from time import time_ns
|
|
3
1
|
from typing import Tuple, Any, Callable, Union, Optional, List
|
|
4
2
|
from dataclasses import dataclass, asdict
|
|
5
3
|
from collections import defaultdict
|
|
@@ -10,6 +8,17 @@ from usearch.io import load_matrix
|
|
|
10
8
|
from usearch.index import Index, Matches, MetricKind, MetricKindBitwise
|
|
11
9
|
|
|
12
10
|
|
|
11
|
+
# For compatibility with Python 3.6
|
|
12
|
+
try:
|
|
13
|
+
from time import time_ns
|
|
14
|
+
except ImportError:
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
|
|
17
|
+
def time_ns():
|
|
18
|
+
now = datetime.now()
|
|
19
|
+
return int(now.timestamp() * 1e9)
|
|
20
|
+
|
|
21
|
+
|
|
13
22
|
def random_vectors(
|
|
14
23
|
count: int,
|
|
15
24
|
metric: MetricKind = MetricKind.IP,
|
|
@@ -246,7 +255,7 @@ class AddTask:
|
|
|
246
255
|
self.labels = self.labels[new_order]
|
|
247
256
|
self.vectors = self.vectors[new_order, :]
|
|
248
257
|
|
|
249
|
-
def slices(self, batch_size: int) ->
|
|
258
|
+
def slices(self, batch_size: int) -> list:
|
|
250
259
|
"""Splits this dataset into smaller chunks."""
|
|
251
260
|
|
|
252
261
|
return [
|
|
@@ -255,7 +264,7 @@ class AddTask:
|
|
|
255
264
|
vectors=self.vectors[start_row:start_row+batch_size, :],
|
|
256
265
|
) for start_row in range(0, self.count, batch_size)]
|
|
257
266
|
|
|
258
|
-
def clusters(self, number_of_clusters: int) ->
|
|
267
|
+
def clusters(self, number_of_clusters: int) -> list:
|
|
259
268
|
"""Splits this dataset into smaller chunks."""
|
|
260
269
|
|
|
261
270
|
from sklearn.cluster import KMeans
|
|
@@ -291,7 +300,7 @@ class SearchTask:
|
|
|
291
300
|
recall_at_one=results.recall_first(self.neighbors[:, 0].flatten()),
|
|
292
301
|
)
|
|
293
302
|
|
|
294
|
-
def slices(self, batch_size: int) ->
|
|
303
|
+
def slices(self, batch_size: int) -> list:
|
|
295
304
|
"""Splits this dataset into smaller chunks."""
|
|
296
305
|
|
|
297
306
|
return [
|
|
@@ -312,7 +321,7 @@ class Evaluation:
|
|
|
312
321
|
def for_dataset(
|
|
313
322
|
dataset: Dataset,
|
|
314
323
|
batch_size: int = 0,
|
|
315
|
-
clusters: int = 1)
|
|
324
|
+
clusters: int = 1):
|
|
316
325
|
|
|
317
326
|
tasks = []
|
|
318
327
|
add = AddTask(
|