usearch 0.16.3 → 0.17.1
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/.github/workflows/prerelease.yml +31 -1
- package/Cargo.toml +1 -1
- package/conanfile.py +1 -1
- package/package.json +1 -1
- package/python/scripts/test.py +3 -1
- package/python/usearch/eval.py +8 -14
|
@@ -17,7 +17,7 @@ permissions:
|
|
|
17
17
|
|
|
18
18
|
jobs:
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
test_python_311:
|
|
21
21
|
name: Test Python
|
|
22
22
|
runs-on: ${{ matrix.os }}
|
|
23
23
|
strategy:
|
|
@@ -41,6 +41,36 @@ jobs:
|
|
|
41
41
|
- name: Test with PyTest
|
|
42
42
|
run: pytest python/scripts/test.py
|
|
43
43
|
|
|
44
|
+
|
|
45
|
+
test_python_36:
|
|
46
|
+
name: Test Python 3.6
|
|
47
|
+
runs-on: ${{ matrix.os }}
|
|
48
|
+
strategy:
|
|
49
|
+
matrix:
|
|
50
|
+
os: [ubuntu-20.04]
|
|
51
|
+
python-version: ["3.6"]
|
|
52
|
+
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@v3
|
|
55
|
+
- run: git submodule update --init --recursive
|
|
56
|
+
|
|
57
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
58
|
+
uses: actions/setup-python@v4
|
|
59
|
+
with:
|
|
60
|
+
python-version: ${{ matrix.python-version }}
|
|
61
|
+
|
|
62
|
+
- name: Install dependencies
|
|
63
|
+
run: |
|
|
64
|
+
python -m pip install --upgrade pip
|
|
65
|
+
pip install pytest numpy dataclasses
|
|
66
|
+
|
|
67
|
+
- name: Build locally
|
|
68
|
+
run: python -m pip install .
|
|
69
|
+
|
|
70
|
+
- name: Test with PyTest
|
|
71
|
+
run: pytest python/scripts/test.py
|
|
72
|
+
|
|
73
|
+
|
|
44
74
|
test_javascript:
|
|
45
75
|
name: Test JavaScript
|
|
46
76
|
runs-on: ubuntu-latest
|
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.
|
|
7
|
+
version = '0.17.1'
|
|
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/scripts/test.py
CHANGED
|
@@ -6,6 +6,7 @@ from usearch.io import load_matrix, save_matrix
|
|
|
6
6
|
from usearch.eval import recall_members, random_vectors
|
|
7
7
|
|
|
8
8
|
from usearch.index import Index, SparseIndex, MetricKind, ScalarKind, Matches
|
|
9
|
+
from usearch.index import _normalize_dtype
|
|
9
10
|
from usearch.index import (
|
|
10
11
|
DEFAULT_CONNECTIVITY,
|
|
11
12
|
DEFAULT_EXPANSION_ADD,
|
|
@@ -131,7 +132,8 @@ def test_index_batch(
|
|
|
131
132
|
assert matches.counts.shape[0] == batch_size
|
|
132
133
|
assert np.all(np.sort(index.labels) == np.sort(labels))
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
if _normalize_dtype(numpy_type) == _normalize_dtype(index_type):
|
|
136
|
+
assert recall_members(index, exact=True) == 1
|
|
135
137
|
|
|
136
138
|
|
|
137
139
|
@pytest.mark.parametrize('ndim', dimensions)
|
package/python/usearch/eval.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
from typing import Tuple, Any, Callable, Union, Optional, List
|
|
2
|
-
from dataclasses import dataclass, asdict
|
|
1
|
+
from typing import Tuple, Any, Callable, Union, Optional, List, NamedTuple
|
|
3
2
|
from collections import defaultdict
|
|
4
3
|
|
|
5
4
|
import numpy as np
|
|
@@ -90,8 +89,7 @@ def measure_seconds(f: Callable) -> Tuple[float, Any]:
|
|
|
90
89
|
return secs, result
|
|
91
90
|
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
class Dataset:
|
|
92
|
+
class Dataset(NamedTuple):
|
|
95
93
|
|
|
96
94
|
labels: np.ndarray
|
|
97
95
|
vectors: np.ndarray
|
|
@@ -165,8 +163,7 @@ class Dataset:
|
|
|
165
163
|
return d
|
|
166
164
|
|
|
167
165
|
|
|
168
|
-
|
|
169
|
-
class TaskResult:
|
|
166
|
+
class TaskResult(NamedTuple):
|
|
170
167
|
|
|
171
168
|
add_operations: Optional[int] = None
|
|
172
169
|
add_per_second: Optional[float] = None
|
|
@@ -193,7 +190,7 @@ class TaskResult:
|
|
|
193
190
|
def search_seconds(self) -> float:
|
|
194
191
|
return self.search_operations / self.search_per_second
|
|
195
192
|
|
|
196
|
-
def __add__(self, other
|
|
193
|
+
def __add__(self, other):
|
|
197
194
|
result = TaskResult()
|
|
198
195
|
if self.add_operations and other.add_operations:
|
|
199
196
|
result.add_operations = self.add_operations + other.add_operations
|
|
@@ -220,8 +217,7 @@ class TaskResult:
|
|
|
220
217
|
return result
|
|
221
218
|
|
|
222
219
|
|
|
223
|
-
|
|
224
|
-
class AddTask:
|
|
220
|
+
class AddTask(NamedTuple):
|
|
225
221
|
|
|
226
222
|
labels: np.ndarray
|
|
227
223
|
vectors: np.ndarray
|
|
@@ -284,8 +280,7 @@ class AddTask:
|
|
|
284
280
|
) for rows in partitioning.values()]
|
|
285
281
|
|
|
286
282
|
|
|
287
|
-
|
|
288
|
-
class SearchTask:
|
|
283
|
+
class SearchTask(NamedTuple):
|
|
289
284
|
|
|
290
285
|
queries: np.ndarray
|
|
291
286
|
neighbors: np.ndarray
|
|
@@ -310,8 +305,7 @@ class SearchTask:
|
|
|
310
305
|
) for start_row in range(0, self.queries.shape[0], batch_size)]
|
|
311
306
|
|
|
312
307
|
|
|
313
|
-
|
|
314
|
-
class Evaluation:
|
|
308
|
+
class Evaluation(NamedTuple):
|
|
315
309
|
|
|
316
310
|
tasks: List[Union[AddTask, SearchTask]]
|
|
317
311
|
count: int
|
|
@@ -362,5 +356,5 @@ class Evaluation:
|
|
|
362
356
|
index.clear()
|
|
363
357
|
return {
|
|
364
358
|
**index.specs,
|
|
365
|
-
**
|
|
359
|
+
**task_result._asdict(),
|
|
366
360
|
}
|